Skip to content

CreateMapObject

Places one of the game’s meshes on the level, for every player.

The object stands at (x, y, z) for everyone in the world now and everyone who joins later. z below 0 = on the ground there, which needs the level’s heightmap or navmesh on the server (the terrain guide); without them give z (GetPlayerPos has it). Players and the server’s collision meet it unless solid = false; the server learns a mesh’s shape from the first admin’s game that draws one, then its collision and its actors’ paths (MoveActor, FindPath) know every object of that mesh (nav says how). With persist = false it lasts for this run of the mode only - make it again in OnGameModeInit. A new layer name makes the layer, switched on. One of the game’s own ladders (the meshes the levels climb: ladder_rustic_225 .. ladder_rustic_575, ladder_siege_10m and ladder_siege_10m_long in objects/manmade/common_fixtures/ladders/) is climbed like the level’s while it is solid and not stretched: lean its top against a wall or a loft’s edge (a pitch of 5 to 15 degrees, as the level’s lean) with its foot on the ground, and its climb is on the open side; a scale makes the climb longer or shorter with it.

CreateMapObject(mesh, x, y, z [, opts])
Parameter Type
mesh string the mesh’s path in the game’s files (the meshes list)
x number metres
y number metres
z number metres; below 0 = on the ground
opts table any of yaw, pitch, roll (degrees), scale (0.05 .. 20, 1; or {x, y, z} - a mesh stretched along its own axes, each 0.05 .. 20), material (one of the game’s in place of the mesh’s own), tint (0xRRGGBBAA), solid (true; one of the game’s chairs never blocks a player, as the level’s do not - the server’s collision still meets it), nav (what the server’s actors make of it: "auto" / "block" in their way, "walkable" they walk on it - a bridge, a ramp -, "ignore" left out; "auto"), view (how far away it is still drawn, 1 .. 255 - 255 as far as the game draws; 0 = by its size), lod (how soon the game swaps in the mesh’s simpler models as players move away, 1 .. 255: 100 is the game’s normal; higher swaps sooner and draws lighter - a town of many buildings - 255 the soonest; lower keeps the detailed model farther; 0 = the game’s own), layer ("base"), group (a folder for the editor), persist (true), use (a use prompt players see on it - OnPlayerUseMapObject hears the key; ""), params (a chair’s: "table" sits the player at a table - the game’s at-a-table pose; none = sitting on their own), attach (the id of the map object it sits on: it moves, turns and stretches with that one and goes when that one is deleted - a lamp on a cart, a sign on a wall; 0 = none), rain (true: a roof keeps the rain out under it, as the level’s own roofs do; false lets it fall through - an awning of cloth, a pergola) (optional)

number - the object’s id; nil and the reason when the server has no map, the map is read-only or a value is out of its bounds

-- a market stall facing the square, for this run of the mode only
function OnGameModeInit()
local id, why = CreateMapObject("objects/manmade/structures/market/market_stall_a.cgf", 1290, 1095, -1,
{yaw = 180, persist = false, layer = "market"})
if not id then Log("no stall: " .. why) end
end

SetMapObject · DeleteMapObject · GetMapObject · GetMapObjectsNear · SetMapLayer · the The server’s map group of the index