Skip to content

World

Lua calls World:method(...). Scripts cannot touch the raw map object; use these helpers instead of World.Map. When the world host is unavailable, queries return nil and mutations do nothing. A bound host with no active map returns nil for views and handles, 0 for numeric queries, false for predicates, or a default time token for getTime().

Source: Content/Lua/World.lua.

Methods

Lua call Arguments Returns Notes
World:addCreatureToWorld(creature) creature: Player or EntityView or Creature or nil — Detached creature, normally from spawnCreature; already added, removed, dead/dying, player, World-owner, nil and flora-backed values do nothing. no return value — No result. Add a fresh, detached living entity to the world once.
World:addItemToWorld(item) item: Item or SpawnedItemView or nil — Detached item, normally from getNewItem; already added, removed, inventoried/contained, registered, pending-drop, dead and nil values do nothing. no return value — No result. Add a fresh, detached item once through the server-owned item path; this does not transfer existing ownership.
World:addStaticLightSource(position, tileLightWidth) position: Vector2 — Light center in world pixels.
tileLightWidth: number — Light radius in tiles, truncated to an integer by the host.
StaticLightHandle or nil — Opaque removal handle, or nil when the position has no chunk or the world host is unavailable. Add a static light and retain its handle for removal.
World:betterExplosion(location, power, tileRange, blockDestruction, simple, source) location: Vector2 — Explosion center in world pixels.
power: number — Explosion power.
tileRange: number — Explosion radius in tiles.
blockDestruction: boolean — Allow tile destruction when simple is false.
simple: boolean — Skip tile/prefab/item destruction and the explosion post-effect when true.
source: Player or EntityView or Creature or Item or Projectile or OwnerToken or nil (optional) — Entity credited for mob damage; nil gives no source, and the source can still be harmed.
no return value — No result. Create an explosion with explicit block destruction, simple-mode, and damage-source controls.
World:betterExplosion(location, power, tileRange, blockDestruction, simple) location: Vector2 — Explosion center in world pixels.
power: number — Explosion power.
tileRange: number — Explosion radius in tiles.
blockDestruction: boolean — Allow tile destruction when simple is false.
simple: boolean — Skip tile/prefab/item destruction and the explosion post-effect when true.
no return value — No result. Create an explosion with explicit block destruction, simple-mode, and damage-source controls.
World:createExplosion(location, power, tileRange, doTileDamage) location: Vector2 — Explosion center in world pixels.
power: number — Explosion power.
tileRange: number — Explosion radius in tiles.
doTileDamage: boolean (optional) — Defaults to true; false also skips prefab/item destruction and the explosion post-effect.
no return value — No result. Create an explosion; disabling tile damage selects the engine's simple explosion path.
World:createExplosion(location, power, tileRange) location: Vector2 — Explosion center in world pixels.
power: number — Explosion power.
tileRange: number — Explosion radius in tiles.
no return value — No result. Create an explosion; disabling tile damage selects the engine's simple explosion path.
World:createFlora(floraStringID, posX, posY, growthPercent) floraStringID: string — Registered flora identifier.
posX: number — World X position in pixels.
posY: number — World Y position in pixels.
growthPercent: boolean or number (optional) — Initial growth fraction, normally 0 to 1; omitted or legacy boolean values mean 0.
Flora or nil — Flora proxy, or nil on a remote client, for an unknown identifier, or without a world host. Create and add pack flora to the world on the host.
World:createFlora(floraStringID, posX, posY) floraStringID: string — Registered flora identifier.
posX: number — World X position in pixels.
posY: number — World Y position in pixels.
Flora or nil — Flora proxy, or nil on a remote client, for an unknown identifier, or without a world host. Create and add pack flora to the world on the host.
World:createProjectile(projectileTypeString, locX, locY, velX, velY) projectileTypeString: string — Registered projectile identifier or supported built-in projectile name.
locX: number — World X position in pixels.
locY: number — World Y position in pixels.
velX: number — Initial X velocity.
velY: number — Initial Y velocity.
Projectile or nil — Projectile proxy, or nil when the type is unknown or the world host is unavailable. Create a projectile and register it for world simulation and drawing. No separate add call is required.
World:createStatusEffect(statusEffectType, intensity, duration, target) statusEffectType: string — Exact registered custom StatusEffectTypeString (pack.identifier), or a case-insensitive built-in enum name or legacy alias.
intensity: number — Effect intensity, interpreted by the selected effect type.
duration: number — Effect duration in milliseconds.
target: Player or EntityView or Creature or nil — Affected living entity; use the same target when attaching the effect.
StatusEffectHandle or nil — Opaque effect handle, or nil for an unsupported type or without a world host. Create a status-effect handle for a target; attach it separately through Player.AddStatusEffect or EntityView.AddStatusEffect.
World:findClosestTarget(location, pixelRange, requireLOS, ignoreEntity, targetKind, typeId, tag) location: Vector2 — Search center in world pixels.
pixelRange: number — Search radius in pixels.
requireLOS: boolean — Require line of sight to the target.
ignoreEntity: Player or EntityView or Creature or nil (optional) — Player or mob to exclude, including the attack owner.
targetKind: string or nil (optional) — all (default), players, or mobs. Players means actual players; mobs includes human NPCs. Unknown kinds raise an error.
typeId: string or nil (optional) — Exact TypeId to require; nil accepts any content type.
tag: string or nil (optional) — Exact authored tag to require; nil accepts any tag.
EntityView or nil — Closest living-entity view, or nil when no target matches or the world host is unavailable. Find the closest valid, living target matching all supplied filters.
World:findClosestTarget(location, pixelRange, requireLOS) location: Vector2 — Search center in world pixels.
pixelRange: number — Search radius in pixels.
requireLOS: boolean — Require line of sight to the target.
EntityView or nil — Closest living-entity view, or nil when no target matches or the world host is unavailable. Find the closest valid, living target matching all supplied filters.
World:findRandomTarget(location, pixelRange, requireLOS, ignoreEntity, targetKind, typeId, tag) location: Vector2 — Search center in world pixels.
pixelRange: number — Search radius in pixels.
requireLOS: boolean — Require line of sight to the target.
ignoreEntity: Player or EntityView or Creature or nil (optional) — Player or mob to exclude, including the attack owner.
targetKind: string or nil (optional) — all (default), players, or mobs. Players means actual players; mobs includes human NPCs. Unknown kinds raise an error.
typeId: string or nil (optional) — Exact TypeId to require; nil accepts any content type.
tag: string or nil (optional) — Exact authored tag to require; nil accepts any tag.
EntityView or nil — Random living-entity view, or nil when no target matches or the world host is unavailable. Choose a random valid, living target matching all supplied filters.
World:findRandomTarget(location, pixelRange, requireLOS) location: Vector2 — Search center in world pixels.
pixelRange: number — Search radius in pixels.
requireLOS: boolean — Require line of sight to the target.
EntityView or nil — Random living-entity view, or nil when no target matches or the world host is unavailable. Choose a random valid, living target matching all supplied filters.
World:getEntitiesTouchingCircle(globalPosition, pixelRange) globalPosition: Vector2 — Circle center in world pixels.
pixelRange: number — Circle radius in pixels.
QueryList<EntityView> or nil — Readonly zero-based view list with Count, or nil when nothing overlaps or the world host is unavailable. Find living entities whose bounds overlap a circle using the center chunk's nearby-mob list.
World:getFloraBaseWidth(floraStringID) floraStringID: string or nil — Registered flora identifier; nil requests the engine's default width of 20 pixels. integer or nil — Width in pixels, or nil when the world host is unavailable. Read the configured stump base width for a flora type.
World:getNearbyStructures(globalPosition, structureID, pixelRange) globalPosition: Vector2 — Search center in world pixels.
structureID: string — Structure type identifier.
pixelRange: number — Search radius in pixels.
QueryList<Structure> or nil — Readonly zero-based proxy list with Count; empty when no structure matches, or nil without a world host. Find matching structures within a world-space radius in the surrounding chunks.
World:getNearestFlora(posX, posY) posX: number — World X position in pixels.
posY: number — World Y position in pixels.
EntityView or nil — Flora-backed view, or nil if none is found; position is readable but its setters do nothing. Find the nearest flora among the local chunk and surrounding chunks.
World:getNewItem(fullItemUniqueString) fullItemUniqueString: string — Full registered item identifier. SpawnedItemView or nil — Mutable spawn view, or nil when no item can be created or the world host is unavailable; this is not an Item script proxy. Construct an item without adding it to the world; set its position and velocity, then call addItemToWorld.
World:getTile(tileX, tileY) tileX: integer — Tile column, not a pixel coordinate.
tileY: integer — Tile row, not a pixel coordinate.
TileView or nil — Readonly tile view, or nil when the world host is unavailable. Read a tile ID through a TileView without exposing the map or tile object.
World:getTileDensity(tileX, tileY) tileX: integer — Tile column.
tileY: integer — Tile row.
integer or nil — Tile density, or nil when the world host is unavailable. Read a foreground tile's density using the world's horizontal wrap.
World:getTileHitSound(tileX, tileY) tileX: integer — Tile column.
tileY: integer — Tile row.
string or nil — Sound label, or nil when the tile has no sound data or the world host is unavailable. Read a foreground tile's configured hit-sound label using the world's horizontal wrap.
World:getTime() None TimeToken or nil — Timestamp token, or nil when the world host is unavailable; no timestamp members are exposed. Capture an opaque wall-clock timestamp for getTimeDiffMS.
World:getTimeDeltaMS() None number or nil — Frame duration in milliseconds, or nil when the world host is unavailable. Read the elapsed simulation time for the current frame.
World:getTimeDiffMS(time1, time2) time1: TimeToken — First timestamp token.
time2: TimeToken — Second timestamp token.
number or nil — Absolute difference in milliseconds, or nil when the world host is unavailable. Measure the absolute wall-clock difference between two tokens from getTime.
World:isCoveringType(tileX, tileY) tileX: integer — Tile column.
tileY: integer — Tile row.
boolean or nil — True for a covering tile, false otherwise, or nil when the world host is unavailable. Test whether a tile is a covering tile.
World:isEventActive(eventTag) eventTag: string — Case-insensitive event tag; currently HALLOWEEN is supported. boolean or nil — Whether the event is active, or nil when the world host is unavailable. Check whether a supported world event is active.
World:isHost() None boolean or nil — True for an offline game or session host, false for a remote client, or nil without a world host. This does not change or replicate operations. Check whether this instance owns the world simulation.
World:playParticleEffectOnce(particleEffectPath, particleEmitPosition) particleEffectPath: string — Particle effect asset path.
particleEmitPosition: Vector2 or nil — World position in pixels; nil emits nothing.
no return value — No result. Emit a particle effect once at a world position.
World:playSpriterFX(uniqueIDString, targetEntity) uniqueIDString: string — Registered Spriter effect identifier.
targetEntity: Player or EntityView or Creature or Item or Projectile or OwnerToken or nil — Entity to follow; nil or a flora-backed EntityView uses the world origin.
no return value — No effect handle is returned. Play a Spriter effect attached to a supported entity proxy.
World:popItem(locX, locY, uniqueItemTypeID) locX: number — World X position in pixels.
locY: number — World Y position in pixels.
uniqueItemTypeID: string — Registered item identifier.
no return value — No item proxy is returned. Spawn an item with a small random upward velocity through the local player's item-spawn path.
World:removeStaticLightSource(lightSource) lightSource: StaticLightHandle or nil — Light handle; nil does nothing. no return value — No result. Remove a static light using the handle returned by addStaticLightSource.
World:setCoveringType(tileX, tileY, coveringTypeID) tileX: integer — Tile column.
tileY: integer — Tile row.
coveringTypeID: integer — Covering type ID, converted to a byte by the host.
no return value — No result. Change a tile's covering type.
World:spawnCreature(creatureStringID) creatureStringID: string — Built-in creature name or registered pack creature identifier. EntityView or nil — Living-entity view, or nil for an unknown type or without a world host; this is not a Creature script proxy. Construct a creature without adding it to the world; set its position and then call addCreatureToWorld.
World:spawnItem(locX, locY, uniqueItemTypeID, rotation, velX, velY, isThrown) locX: number — World X position in pixels.
locY: number — World Y position in pixels.
uniqueItemTypeID: string — Registered item identifier.
rotation: number (optional) — Required in the seven-argument form; currently ignored by the engine's spawn path.
velX: number (optional) — Initial X velocity; defaults to 0 only in the three-argument form.
velY: number (optional) — Initial Y velocity; defaults to 0 only in the three-argument form.
isThrown: boolean (optional) — Required in the seven-argument form; currently ignored by the engine's spawn path.
no return value — No item proxy is returned. Spawn an item using either three arguments or the complete seven-argument form.
World:spawnItem(locX, locY, uniqueItemTypeID) locX: number — World X position in pixels.
locY: number — World Y position in pixels.
uniqueItemTypeID: string — Registered item identifier.
no return value — No item proxy is returned. Spawn an item using either three arguments or the complete seven-argument form.
CLR declaration reference

These names identify the backing engine source declarations.

  • LuaWorldHost.AddCreatureToWorld
  • LuaWorldHost.AddItemToWorld
  • LuaWorldHost.AddStaticLightSource
  • LuaWorldHost.BetterExplosion
  • LuaWorldHost.CreateExplosion
  • LuaWorldHost.CreateFlora
  • LuaWorldHost.CreateProjectile
  • LuaWorldHost.CreateStatusEffect
  • LuaWorldHost.FindClosestTarget
  • LuaWorldHost.FindRandomTarget
  • LuaWorldHost.GetEntitiesTouchingCircle
  • LuaWorldHost.GetFloraBaseWidth
  • LuaWorldHost.GetNearbyStructures
  • LuaWorldHost.GetNearestFlora
  • LuaWorldHost.GetNewItem
  • LuaWorldHost.GetTile
  • LuaWorldHost.GetTileDensity
  • LuaWorldHost.GetTileHitSound
  • LuaWorldHost.GetTime
  • LuaWorldHost.GetTimeDeltaMS
  • LuaWorldHost.GetTimeDiffMS
  • LuaWorldHost.IsCoveringType
  • LuaWorldHost.IsEventActive
  • LuaWorldHost.IsHost
  • LuaWorldHost.PlayParticleEffectOnce
  • LuaWorldHost.PlaySpriterFX
  • LuaWorldHost.LocalPlayerSpawnItem
  • LuaWorldHost.RemoveStaticLightSource
  • LuaWorldHost.SetCoveringType
  • LuaWorldHost.SpawnCreature
  • LuaWorldHost.LocalPlayerSpawnItem

Generated 2026-10-02T21:05:27.5090099Z · b8c9ae78 · 31 members.

Official modding overview · Signs of Life on Steam