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:
sm.world.ids
Predefined special world ids
| anyWorld |
| noWorld |
sm.world.voxelFilter table
Filters are used to specify what materials a terrain modification sphere can destroy.
The filters are:
- material0 – Allows destruction of material 0 in the voxel material set.
- material1 – Allows destruction of material 1 in the voxel material set.
- material2 – Allows destruction of material 2 in the voxel material set.
- material3 – Allows destruction of material 3 in the voxel material set.
- material4 – Allows destruction of material 4 in the voxel material set.
- material5 – Allows destruction of material 5 in the voxel material set.
- material6 – Allows destruction of material 6 in the voxel material set.
- material7 – Allows destruction of material 7 in the voxel material set.
- all – Allows destruction of all materials in the voxel material set.
| none | 0 |
| material0 | 1 |
| material1 | 2 |
| material2 | 4 |
| material3 | 8 |
| material4 | 16 |
| material5 | 32 |
| material6 | 64 |
| material7 | 128 |
| all | 255 |
sm.world.createWorld(filename, classname, terrainParams?, seed?)
Server only
Creates a new world object.
Parameters:
| Type | Name | Description |
|---|---|---|
| string | filename | The world script filename. |
| string | classname | The world script class name. |
| any | terrainParams? | The world's terrain parameters. (Optional) |
| integer | seed? | The world's seed. Defaults to 0 (Optional) |
Returns:
| Type | Description |
|---|---|
| World | The created world object. |
sm.world.getCurrentWorld()
Get the world that the scripted object is in.
Returns:
| Type | Description |
|---|---|
| World | The world |
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.
Parameters:
| Type | Name | Description |
|---|---|---|
| Vec3 | position? | The world position of the sphere. (Optional) |
| number | radius? | The radius of the sphere. (Optional) |
Returns:
| Type | Description |
|---|---|
| table | The table of tables. { {center=Vec3, radius=number}, ..} |
sm.world.getLegacyCreativeWorld()
Server only
Gets a previously saved creative world
Returns:
| Type | Description |
|---|---|
| World | The world (id 0) if it exists in the database or nil |
sm.world.loadWorld(world)
Server only
Loads a previously created world.
Parameters:
| Type | Name | Description |
|---|---|---|
| World | world | The world that should be loaded. |
Returns:
| Type | Description |
|---|---|
| boolean | Return true if the world was loaded. |