sm

The sm namespace contain all API features related to Scrap Mechanic.

Constants:

Functions:

  • exists
  • isServerMode

  • sm.isHost boolean

    Returns whether the game is currently running on the hosting player's computer.


    sm.types table

    Lua types

    nil
    boolean
    number
    string
    function
    userdata
    thread
    table
    uuid
    vec3
    quat
    color
    raycastResult
    loadCellHandle
    effect
    shape
    body
    interactable
    container
    harvestable
    network
    world
    unit
    storage
    player
    character
    joint
    aiState
    quest
    areaTrigger
    portal
    pathNode
    lift
    scriptableObject
    builderGuide
    cullSphereGroup
    voxelTerrain
    jsonGui
    jsonWidget
    clientScriptableObject

    sm.version string

    Returns the current version of the game as a string.


    sm.exists(object)

    Returns whether an object exists in the game. This is useful for checking whether a reference to an object is valid.

    Parameters:

    TypeNameDescription
    anyobjectThe object instance.

    Returns:

    TypeDescription
    booleanWhether the object exists.

    sm.isServerMode()

    Returns whether the script is currently running in server mode. Otherwise, it is running in client mode. Server mode only occurs when sm.isHost is true.

    Returns:

    TypeDescription
    booleanWhether the script is running in server mode.