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
  • getCurrentWorld
  • getDirtySpheres
  • getLegacyCreativeWorld
  • loadWorld

  • sm.world.ids

    Predefined special world ids

    anyWorld
    noWorld

    sm.world.createWorld(filename, classname, terrainParams=nil, seed=0)

    Server only

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

    Parameters:

    TypeNameDescription
    stringfilenameThe world script filename.
    stringclassnameThe world script class name.
    anyterrainParams=nilThe world's terrain parameters. (Optional)
    integerseed=0The world's seed. Defaults to 0 (Optional)

    Returns:

    TypeDescription
    WorldThe created world object.

    sm.world.getCurrentWorld()

    Get the world that the scripted object is in.

    Returns:

    TypeDescription
    WorldThe world

    sm.world.getDirtySpheres(position=nil, radius=nil)

    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:

    TypeNameDescription
    Vec3position=nilThe world position of the sphere. (Optional)
    numberradius=nilThe radius of the sphere. (Optional)

    Returns:

    TypeDescription
    tableThe table of tables. { {center=Vec3, radius=number}, ..}

    sm.world.getLegacyCreativeWorld()

    Server only

    Gets a previously saved creative world

    Returns:

    TypeDescription
    WorldThe world (id 0) if it exists in the database or nil

    sm.world.loadWorld(world)

    Server only

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

    Parameters:

    TypeNameDescription
    WorldworldThe world that should be loaded.

    Returns:

    TypeDescription
    booleanReturn true if the world was loaded.