Skip to main content

sm.tool

Associated object type: Tool

A Tool is a scripted item that 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 custom scripted tools, see ToolClass.

Constants

interactState

The tool's input interaction state.

sm.tool.interactState = {
null = 0, --No interaction.
start = 1, --The key was just pressed.
hold = 2, --The key is held down.
stop = 3 --The key was just released.
}

Functions

checkLiftCollision

local collides, level = sm.tool.checkLiftCollision(creation, position, rotation)

Used to check collisions between a lift creation and the world.

Parameters:

  • creation (table): A table of all the bodies belonging to the creation placed on the lift.
  • position (Vec3): The lift position.
  • rotation (int): The rotation of the creation on the lift.

Returns:

  • collides (boolean): Whether the lift collides with the world or not.
  • level (int): The lift level.

forceTool

sm.tool.forceTool(tool)

Client-Only

Force-equips a tool for the local player.
Pass nil to unforce an already forced tool.
This cannot be used to force-unequip a tool.

Parameters:

  • tool (Tool): The tool.

preloadRenderables

sm.tool.preloadRenderables(renderables)

Client-Only

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

Parameters:

  • renderables (table): The table of renderable file paths.

uuidExists

local exists = sm.tool.uuidExists(uuid)

Returns whether a tool with the given UUID exists.

Parameters:

  • uuid (Uuid): The UUID.

Returns:

  • exists (boolean): Whether the uuid exists or not.