Skip to main content

sm.world

Associated object type: World

The world API handles the creation and destruction of worlds.

A world contains the terrain and simulates the physics environment in which other game objects can exist.

Constants

Functions

createWorld

sm.world.createWorld( filename, classname, terrainParams, seed )
Server-Only

Creates a new world object. Can only be called from inside the Game script environment.

Arguments:
  • filename [ string ]: The path to the world script file.
  • classname [ string ]: The name of the world script class name.
  • terrainParams [ any ]: Any extra terrain parameters. Optional.
  • seed [ int ]: The world seed. Defaults to 0.
Returns:

getCurrentWorld

sm.world.getCurrentWorld()

Get the world that the scripted object is in.

Returns:

getDirtySpheres

sm.world.getDirtySpheres( position, radius )

Returns an array of tables representing spheres where something has changed in the world.

The optional position and radius parameters will construct a sphere, and use it as a filter to only show results that intersect that sphere.

Arguments:
  • position [ Vec3 ]: The position of the sphere. Optional.
  • radius [ number ]: The size of the sphere. Optional.
Returns:
  • [ table ]: A table containing tables of changed spheres. See structure below.
Table Structure
{
{
center = vec3, --The sphere's position
radius = number --The sphere's size.
}
}

getLegacyCreativeWorld

sm.world.getLegacyCreativeWorld()
Server-Only

Gets a previously saved creative world.

Returns:
  • [ World ]: The world (id 0) if it exists in the database or nil.

loadWorld

sm.world.loadWorld( world )
Server-Only

Loads a previously created world.
Can only be called from inside the Game script environment.

Arguments:
Returns:
  • [ bool ]: Whether the world was loaded successfully or not.