sm.tool

A tool is a scripted tool a player holds in their hand. The tool object is focused on handling animations for first and third person view.

For more information about creating your own scripted tools, see ToolClass.

Constants

Name Type Description
interactState table The interact state list.

interactState

Value type: table

The interact state describe what kind of interaction is made. This is used to check whether a mouse button or key was just made pressed, held, etc.

The states are:

  • null – No keypress was made.
  • start – The key was just pressed.
  • hold – The key is held down.
  • stop – The key was just released.
{
    null  = 0,
    start = 1,
    hold  = 2,
    stop  = 3,
}

Server + Client

checkLiftCollision

sm.tool.checkLiftCollision( creation, position, rotation )

Used to check collisions between the lift and the world.

Parameters:

Name Type Description
creation table A table of all the bodies belonging to the creation placed on the lift.
position Vec3 The lift position.
rotation integer The rotation of the creation on the lift.

Returns:

Type Description
boolean True if the lift collides with the world
integer The lift level.

checkLiftCollisionAtLevel

sm.tool.checkLiftCollisionAtLevel(
    creation,
    position,
    rotation,
    level,
    timeStamp
)

Checks whether a specific lift level is valid (no collision) for a creation at the given position and rotation.

Parameters:

Name Type Description
creation table A table of all the bodies belonging to the creation placed on the lift.
position Vec3 The lift position.
rotation integer The rotation of the creation on the lift.
level integer The specific lift level to test.
timeStamp integer The timestamp of when the body set was initialized

Returns:

Type Description
boolean True if the level is valid (no collision).

findPaintToolPaletteColumnIndex

sm.tool.findPaintToolPaletteColumnIndex(  )

Find index of column of shades that best matches given color.

Returns:

Type Description
integer Palette column index.

getLiftMaxLevel

sm.tool.getLiftMaxLevel(  )

Returns the maximum number of lift levels.

Returns:

Type Description
integer The maximum lift level count.

uuidExists

sm.tool.uuidExists( uuid )

Return whether the tool uuid exists

Parameters:

Name Type Description
uuid Uuid The shape uuid.

Returns:

Type Description
boolean exists.

Client-only

forceTool

sm.tool.forceTool( tool )

Force equip a tool for the local player. Pass nil to unforce an already forced tool.

Parameters:

Name Type Description
tool Tool The tool.

preloadRenderables

sm.tool.preloadRenderables( renderables )

Pre-loads renderable data to be used by the tool. This eliminates excessive loading during run time.

Parameters:

Name Type Description
renderables table The table of renderables names. {string, ..}