Lua functions

Spawn

Historical function name; no current lua_register binding was found.

Historical signature: Spawn(zone, spawn_id, x, y, z, heading)

Parameter and behavior details in the historical explanation are under review against the current implementation.

Function: Spawn(zone, spawn_id, restricted_npc, x, y, z, heading)

Description: Create an actor from a spawn database definition in the supplied zone. A construction owner keeps the new allocation alive while its position and script are prepared. The prespawn callback runs before active publication; cancellation prevents publication. Publication transfers allocation custody to the zone, after which an enabled script receives its spawn callback.

Persistent house-object definitions carrying an inventory receipt cannot be cloned through this generic function, even after settlement. Use their original placed location (for example SpawnByLocationID) so the exact spawn, entry, placement, zone, instance and table set can be validated before publication. Rejected generic creation returns nil.

The nearest-location lookup used during position preparation retains the selected original actor while reading its location. Spatial candidates are bound to their original actor and registration epoch; a replaced runtime ID cannot change an admitted nearest result. The new construction is not spatially published until its metadata registration exists, and target-added notification follows spatial publication.

Parameters:

  • zone (Zone) - Destination zone object.
  • spawn_id (uint32) - Nonzero spawn database ID, not a runtime spawn ID.
  • restricted_npc (uint8) - 1 adds the new actor to its own allow-access list; other values leave that restriction unset.
  • x, y, z (float) - Destination coordinates. At least one coordinate must be nonzero.
  • heading (float) - Heading, defaulting to 0 when omitted.

Returns: The created Spawn object, or nil for invalid arguments, missing or omitted database definition, canceled construction, or rejected admission. Failed construction retires its server allocation.

Checked example

No checked example is published for this function yet. No active lua_register binding in this checkout.

Current registration: WorldServer/Lua/LuaInterface.cpp. Historical explanation: EQ2Emu Lua documentation.