Tool

Associated namespace: sm.tool

A userdata object representing a tool in the game.

Values:

Functions:


id integer

Get:

Returns the id of a tool.


getAnimationInfo(tool, name)

Client only

Returns general information for a third person view animation.

Parameters:

TypeNameDescription
TooltoolThe tool.
stringnameThe name.

Returns:

TypeDescription
tableA table containing "name", "duration" and "looping".

getCameraWeights()

Client only

Get the current weights for the tool's local camera settings.

Returns:

TypeDescription
{number, number}The third-person weight and the first-person weight

getDirection(tool)

Client only

Returns the direction of where the player is viewing or aiming.

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
Vec3The player's view direction.

getFpAnimationInfo(tool, name)

Client only

Returns general information for a first person view animation.

Parameters:

TypeNameDescription
TooltoolThe tool.
stringnameThe name.

Returns:

TypeDescription
tableA table containing "name", "duration" and "looping".

getFpBonePos(tool, jointName)

Client only

Returns the world position for a bone in the first person view animation skeleton.

Parameters:

TypeNameDescription
TooltoolThe tool.
stringjointNameThe joint name.

Returns:

TypeDescription
Vec3The joint position.

getId(tool)

Returns the id of a tool.

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
integerThe tool's id.

getMovementSpeedFraction(tool)

Client only

Returns the fraction of the player's movement speed in proportion to its maximum. This is affected by sprinting, crouching, blocking, aiming, etc.

sprinting 1.0
walking 0.5
crouching 0.375
aiming 0.3125

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
numberThe player's movement speed fraction.

getMovementVelocity(tool)

Client only

Returns the movement velocity of the player.

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
Vec3The player's velocity.

getOwner(tool)

Returns the player that owns the tool.

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
PlayerThe tool's owner.

getPosition(tool)

Client only

Returns the world position of the player.

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
Vec3The player's world position.

getRelativeMoveDirection(tool)

Client only

Returns the relative movement direction of the player. This is the direction the player wants to move based on movement input.

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
Vec3The player's relative movement direction.

getTpBoneDir(tool, jointName)

Client only

Returns the world direction for a bone in the third person view animation skeleton.

Parameters:

TypeNameDescription
TooltoolThe tool.
stringjointNameThe joint name.

Returns:

TypeDescription
Vec3The joint direction.

getTpBonePos(tool, jointName)

Client only

Returns the world position for a bone in the third person view animation skeleton.

Parameters:

TypeNameDescription
TooltoolThe tool.
stringjointNameThe joint name.

Returns:

TypeDescription
Vec3The joint position.

isCrouching(tool)

Client only

Returns whether the player is currently crouching.

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
booleanWhether the player is crouching.

isEquipped(tool)

Client only

Returns whether the the tool is equipped or not.

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
booleanwhether the the tool is equipped or not.

isInFirstPersonView(tool)

Client only

Returns whether the player is in first person view where the viewpoint is rendered from the player's perspective. Otherwise, the player is in third person view where the camera is behind the player.

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
booleanWhether the player is in first person view.

isLocal(tool)

Client only

Returns whether the player holding the tool is the as sm.localPlayer.

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
booleanWhether the player is the local player.

isOnGround(tool)

Client only

Returns whether the player is currently standing on the ground.

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
booleanWhether the player is on the ground.

isSprinting(tool)

Client only

Returns whether the player is currently sprinting.

Parameters:

TypeNameDescription
TooltoolThe tool.

Returns:

TypeDescription
booleanWhether the player is sprinting.

setBlockSprint(tool, block)

Client only

Sets whether the player is unable to sprint. Sprinting is normally blocked when the player is attacking, blocking, aiming, etc.

Parameters:

TypeNameDescription
TooltoolThe tool.
booleanblockWhether the player's sprinting is blocked.

setCrossHairAlpha(tool, alpha)

Client only

Sets the opacity of the crosshair. An alpha value of 0 makes the crosshair transparent.

Parameters:

TypeNameDescription
TooltoolThe tool.
numberalphaThe alpha value for the crosshair.

setDispersionFraction(tool, dispersion)

Client only

Sets the tool's dispersion fraction. This represents the accuracy of the tool, and affects the size of the player's crosshair.

A dispersion value of 0 is perfect accuracy, whereas 1 is the worst.

Parameters:

TypeNameDescription
TooltoolThe tool.
numberdispersionThe dispersion fraction.

setFpColor(tool, color)

Client only

Sets the color to be used for the tool in first person view.

Parameters:

TypeNameDescription
TooltoolThe tool.
ColorcolorThe color.

setFpRenderables(tool, renderables)

Client only

Sets the renderables (files containing model data) to be used for the character in first person view.

Parameters:

TypeNameDescription
TooltoolThe tool.
tablerenderablesThe table of renderables names {string, ..}

setInteractionTextSuppressed(tool, suppressed)

Client only

Sets whether interaction texts are suppressed for the player. This means the player won't be able to see "Press E to use", and similar texts, when looking at an interactable.

Parameters:

TypeNameDescription
TooltoolThe tool.
booleansuppressedWhether interaction texts are suppressed.

setMovementAnimation(tool, name, animation)

Client only

Sets the current third person view movement animation to be used by the tool.

Parameters:

TypeNameDescription
TooltoolThe tool.
stringnameThe name.
stringanimationThe animation.

setMovementSlowDown(tool, slowDown)

Client only

Sets whether the player is slowed down. This is similar to crouching and normally occurs when the player is aiming.

Parameters:

TypeNameDescription
TooltoolThe tool.
booleanslowDownWhether the player movement is slowed down.

setTpColor(tool, color)

Client only

Sets the color to be used for the tool in third person view.

Parameters:

TypeNameDescription
TooltoolThe tool.
ColorcolorThe color.

setTpRenderables(tool, renderables)

Client only

Sets the renderables (files containing model data) to be used for the character in third person view.

Parameters:

TypeNameDescription
TooltoolThe tool.
tablerenderablesThe table of renderables names. {string, ..}

updateAnimation(tool, name, time, weight=-1.0)

Client only

Updates a third person view animation.

Parameters:

TypeNameDescription
TooltoolThe tool.
stringnameThe animation name.
numbertimeThe time.
numberweight=-1.0The weight.

updateCamera(tool, distance, fov, offset, weight)

Client only

Updates the third person view camera for the tool.

Parameters:

TypeNameDescription
TooltoolThe tool.
numberdistanceThe distance.
numberfovThe fov.
Vec3offsetThe offset.
numberweightThe weight.

updateFpAnimation(tool, name, time, weight=-1.0, looping=false)

Client only

Updates a first person view animation.

Parameters:

TypeNameDescription
TooltoolThe tool.
stringnameThe name.
numbertimeThe time.
numberweight=-1.0The weight.
booleanlooping=falseThe looping.

updateFpCamera(tool, fov, offset, weight, bobbing)

Client only

Updates the first person view camera for the tool.

Parameters:

TypeNameDescription
TooltoolThe tool.
numberfovThe fov.
Vec3offsetThe offset.
numberweightThe weight.
numberbobbingThe bobbing.

updateJoint(tool, name, rotation, weight=-1.0)

Client only

Sets the rotation and weight for a bone in the animation skeleton.

Parameters:

TypeNameDescription
TooltoolThe tool.
stringnameThe name.
Vec3rotationThe rotation.
numberweight=-1.0The weight.

updateMovementAnimation(tool, time, weight=-1.0)

Client only

Updates the currently set third person view movement animation for the tool.

Parameters:

TypeNameDescription
TooltoolThe tool.
numbertimeThe time.
numberweight=-1.0The weight.