Skip to main content

World

Associated namespace: sm.world

A userdata object representing a world in the game.

Operations:
OperationDescription
World == WorldChecks if two instances of World refer to the same World.
Values:
  • id [ int ]

    • Get: The world's id.

Functions

destroy

world:destroy()
Server-Only

Destroys the world. Only available in the game script environment.

Arguments:

getId

world:getId()

Returns the world's id.

Arguments:
Returns:
  • [ int ]: The id.

isIndoor

world:isIndoor()

Returns whether the world is an indoor world.

Arguments:
Returns:
  • [ bool ]: Whether the world is an indoor world or not.

loadCell

world:loadCell( x, y, player, callback, params, ref )
Server-Only

Load a cell for player.
The cell will stay loaded until the player steps into the cell,
or the cell is released with releaseCell (and no player is close enough to load the cell).

The callback parameters are ( world, x, y, player, params, handle )

The callback receives:
  • world [ World ]: The world.
  • x [ int ]: The cell's X position.
  • y [ int ]: The cell's Y position.
  • player [ Player ]: The player that was loaded for.
  • params [ any ]: Params passed to loadCell.
  • handle [ LoadCellHandle ]: The cell's LoadCellHandle, for releasing the cell.
Arguments:
  • world [ World ]: The world.
  • x [ int ]: The cell's X position.
  • y [ int ]: The cell's Y position.
  • player [ Player ]: The player to load for. Optional.
  • callback [ string ]: The Lua function to call when the cell is loaded. Optional.
  • params [ any ]: A parameter object passed to the callback function. Optional.
  • ref [ ref ]: The ScriptRef for the callback object. Optional.
Returns:
  • [ int ]: The handle to use when explicitly releasing the cell.

reloadCell

world:reloadCell( x, y, callback, ref )

Reloads a cell.

The callback receives:
  • world [ World ]: The world.
  • x [ int ]: The cell's X position.
  • y [ int ]: The cell's Y position.
  • result [ int ]: The result. 0 = Not reloaded due to cell being inactive. 1 = Successfully reloaded.
Arguments:
  • world [ World ]: The world.
  • x [ int ]: The cell's X position.
  • y [ int ]: The cell's Y position.
  • callback [ string ]: The Lua function to call when the cell is reloaded. Optional.
  • ref [ ref ]: The ScriptRef for the callback object. Optional.

setTerrainScriptData

world:setTerrainScriptData( data )

Set data to pass on to the terrain generation script.
If no data is set, the terrain generation script receives the same data as the world script.

Arguments:
  • world [ World ]: The world.
  • data [ any ]: Any data, available in the terrain script as parameter 6 in the create callback.

terrainSphereModification

world:terrainSphereModification( position, radius, strength )

Modifies destructable terrain with a sphere shape.

Arguments:
  • world [ World ]: The world.
  • position [ Vec3 ]: The world position of the sphere.
  • radius [ number ]: The radius of the sphere.
  • strength [ number ]: The strength of the modification (Optional).