Tool
A userdata object representing a tool in the game.
Values:
-
Get: Returns the id of a tool.
-
uuid[ Uuid ]Get: Returns the tool type uuid.
Server + Client
getId
tool:getId( )
Returns the id of a tool.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| integer | The tool's id. |
getOwner
tool:getOwner( )
Returns the player that owns the tool.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| Player | The tool's owner. |
getUuid
tool:getUuid( )
Returns the tool type uuid.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| Uuid | The tool's uuid. |
setInteractionTextSuppressed
tool:setInteractionTextSuppressed( )
Deprecated: Deprecated function. Kept for compability with old scripts.
Does nothing.
Client-only
getAnimationInfo
tool:getAnimationInfo( name )
Returns general information for a third person view animation.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
name |
string | The name. |
Returns:
| Type | Description |
|---|---|
| table | A table containing "name", "duration" and "looping". |
getCameraWeights
tool:getCameraWeights( )
Get the current weights for the tool's local camera settings.
Returns:
| Type | Description |
|---|---|
| {number, number} | The third-person weight and the first-person weight |
getDirection
tool:getDirection( )
Returns the direction of where the player is viewing or aiming.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The player's view direction. |
getFpAnimationInfo
tool:getFpAnimationInfo( name )
Returns general information for a first person view animation.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
name |
string | The name. |
Returns:
| Type | Description |
|---|---|
| table | A table containing "name", "duration" and "looping". |
getFpBoneDir
tool:getFpBoneDir( jointName, convertToWorldSpace )
Returns the local or world direction for a bone in the first person view animation skeleton.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
jointName |
string | The joint name. |
convertToWorldSpace (optional) |
boolean | Whether to convert the position to world space. (Defaults to true) |
Returns:
| Type | Description |
|---|---|
| Vec3 | The joint direction. |
getFpBonePos
tool:getFpBonePos( jointName, convertToWorldSpace )
Returns the local or world position for a bone in the first person view animation skeleton.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
jointName |
string | The joint name. |
convertToWorldSpace (optional) |
boolean | Whether to convert the position to world space. (Defaults to true) |
Returns:
| Type | Description |
|---|---|
| Vec3 | The joint position. |
getFpBoneRot
tool:getFpBoneRot( jointName, convertToWorldSpace )
Returns the local or world rotation for a bone in the first person view animation skeleton.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
jointName |
string | The joint name. |
convertToWorldSpace (optional) |
boolean | Whether to convert the position to world space. (Defaults to true) |
Returns:
| Type | Description |
|---|---|
| Quat | The joint rotation. |
getMovementSpeedFraction
tool:getMovementSpeedFraction( )
Returns the fraction of the player's movement speed in proportion to its maximum. This is affected by sprinting, crouching, blocking, aiming, etc.
| Value | Description |
|---|---|
| sprinting | 1.0 |
| walking | 0.5 |
| crouching | 0.375 |
| aiming | 0.3125 |
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| number | The player's movement speed fraction. |
getMovementVelocity
tool:getMovementVelocity( )
Returns the movement velocity of the player.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The player's velocity. |
getPosition
tool:getPosition( )
Returns the world position of the player.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The player's world position. |
getRelativeMoveDirection
tool:getRelativeMoveDirection( )
Returns the relative movement direction of the player. This is the direction the player wants to move based on movement input.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The player's relative movement direction. |
getSmoothDirection
tool:getSmoothDirection( )
Returns the smooth direction of where the player is viewing or aiming.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The player's smooth view direction. |
getTpBoneDir
tool:getTpBoneDir( jointName )
Returns the world direction for a bone in the third person view animation skeleton.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
jointName |
string | The joint name. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The joint direction. |
getTpBonePos
tool:getTpBonePos( jointName )
Returns the world position for a bone in the third person view animation skeleton.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
jointName |
string | The joint name. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The joint position. |
getTpBoneRot
tool:getTpBoneRot( jointName )
Returns the world rotations for a bone in the third person view animation skeleton.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
jointName |
string | The joint name. |
Returns:
| Type | Description |
|---|---|
| Quat | The joint rotation. |
isCrouching
tool:isCrouching( )
Returns whether the player is currently crouching.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| boolean | Whether the player is crouching. |
isEquipped
tool:isEquipped( )
Returns whether the tool is equipped or not.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| boolean | whether the tool is equipped or not. |
isInFirstPersonView
tool:isInFirstPersonView( )
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:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| boolean | Whether the player is in first person view. |
isLocal
tool:isLocal( )
Returns whether the player holding the tool is the as sm.localPlayer.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| boolean | Whether the player is the local player. |
isOnGround
tool:isOnGround( )
Returns whether the player is currently standing on the ground.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| boolean | Whether the player is on the ground. |
isSprinting
tool:isSprinting( )
Returns whether the player is currently sprinting.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
Returns:
| Type | Description |
|---|---|
| boolean | Whether the player is sprinting. |
setBlockSprint
tool:setBlockSprint( block )
Sets whether the player is unable to sprint. Sprinting is normally blocked when the player is attacking, blocking, aiming, etc.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
block |
boolean | Whether the player's sprinting is blocked. |
setCrossHairAlpha
tool:setCrossHairAlpha( alpha )
Sets the opacity of the crosshair. An alpha value of 0 makes the crosshair transparent.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
alpha |
number | The alpha value for the crosshair. |
setCrossHairColor
tool:setCrossHairColor( color )
Sets the color of the crosshair.
Parameters:
setCrossHairType
tool:setCrossHairType( type )
Sets the type of the crosshair.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
type |
number | The type value for the crosshair. |
setDispersionFraction
tool:setDispersionFraction( dispersion, dispersionSecondary )
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:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
dispersion |
number | The dispersion fraction. |
dispersionSecondary (optional) |
number | The secondary dispersion fraction for circles. (Optional) |
setFpColor
tool:setFpColor( color )
Sets the color to be used for the tool in first person view.
Parameters:
setFpRenderables
tool:setFpRenderables( renderables )
Sets the renderables (files containing model data) to be used for the character in first person view.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
renderables |
table | The table of renderables names {string, ..} |
setMovementAnimation
tool:setMovementAnimation( name, animation )
Sets the current third person view movement animation to be used by the tool.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
name |
string | The name. |
animation |
string | The animation. |
setMovementSlowDown
tool:setMovementSlowDown( slowDown )
Sets whether the player is slowed down. This is similar to crouching and normally occurs when the player is aiming.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
slowDown |
boolean | Whether the player movement is slowed down. |
setTpColor
tool:setTpColor( color )
Sets the color to be used for the tool in third person view.
Parameters:
setTpRenderables
tool:setTpRenderables( renderables )
Sets the renderables (files containing model data) to be used for the character in third person view.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
renderables |
table | The table of renderables names. {string, ..} |
updateAnimation
tool:updateAnimation( name, time, weight )
Updates a third person view animation.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
name |
string | The animation name. |
time |
number | The time. |
weight (optional) |
number | The weight. (Defaults to -1.0) |
updateCamera
tool:updateCamera( distance, fov, offset, weight )
Updates the third person view camera for the tool.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
distance |
number | The distance. |
fov |
number | The fov. |
offset |
Vec3 | The offset. |
weight |
number | The weight. |
updateFpAnimation
tool:updateFpAnimation( name, time, weight, looping )
Updates a first person view animation.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
name |
string | The name. |
time |
number | The time. |
weight (optional) |
number | The weight. (Defaults to -1.0) |
looping (optional) |
boolean | The looping. (Defaults to false) |
updateFpCamera
tool:updateFpCamera( fov, offset, weight, bobbing )
Updates the first person view camera for the tool.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
fov |
number | The fov. |
offset |
Vec3 | The offset. |
weight |
number | The weight. |
bobbing |
number | The bobbing. |
updateJoint
tool:updateJoint( name, rotation, weight )
Sets the rotation and weight for a bone in the animation skeleton.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
name |
string | The name. |
rotation |
Vec3 | The rotation. |
weight (optional) |
number | The weight. (Defaults to -1.0) |
updateMovementAnimation
tool:updateMovementAnimation( time, weight )
Updates the currently set third person view movement animation for the tool.
Parameters:
| Name | Type | Description |
|---|---|---|
tool |
Tool | The tool. |
time |
number | The time. |
weight (optional) |
number | The weight. (Defaults to -1.0) |