sm
The sm namespace contain all API features related to Scrap Mechanic.
Constants
| Name | Type | Description |
|---|---|---|
isHost |
boolean | Returns whether the game is currently running on the hosting player's computer. |
types |
table | The lua types list. |
version |
string | Returns the current version of the game as a string. |
types
Value type: 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,
}
Functions
exists
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:
| Name | Type | Description |
|---|---|---|
object |
any | The object instance. |
Returns:
| Type | Description |
|---|---|
| boolean | Whether the object exists. |
isServerMode
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:
| Type | Description |
|---|---|
| boolean | Whether the script is running in server mode. |