Tool
Associated namespace: sm.tool
A userdata object representing a handheld tool in the game.
Values:-
id
[ int ]Get
: The tool's id.
Functions
getAnimationInfo
tool:getAnimationInfo( name )
Client-Only
Returns general information for a third person view animation.
Arguments:tool
[ Tool ]: The tool.name
[ string ]: The animation name.
- [ table ]: A table containing information about the animation (see below).
name
[ string ]: The animation's name.duration
[ number ]: The animation's durationlooping
[ bool ]: Whether the animation is looping or not.
getCameraWeights
tool:getCameraWeights()
Client-Only
Returns the current weights for the tool's local camera settings.
Arguments:tool
[ Tool ]: The tool.
- [ number ]: The third-person weight.
- [ number ]: The first-person weight.
getDirection
tool:getDirection()
Client-Only
Returns the player's view/aim direction.
Arguments:tool
[ Tool ]: The tool.
- [ Vec3 ]: The aim direction.
getFpAnimationInfo
tool:getFpAnimationInfo( name )
Client-Only
Returns general information for a first person view animation.
Arguments:tool
[ Tool ]: The tool.name
[ string ]: The animation name.
- [ table ]: A table containing information about the animation (see below).
name
[ string ]: The animation's name.duration
[ number ]: The animation's durationlooping
[ bool ]: Whether the animation is looping or not.
getFpBonePos
tool:getFpBonePos( joint )
Client-Only
Returns the world position for a bone in the first person view animation skeleton.
Arguments:tool
[ Tool ]: The tool.joint
[ string ]: The name of the joint.
- [ Vec3 ]: The joint position.
getId
tool:getId()
Returns the tool's id.
Arguments:tool
[ Tool ]: The tool.
- [ int ]: The tool's id.
getMovementSpeedFraction
tool:getMovementSpeedFraction()
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
blocking
= 0.5
crouching
= 0.375
aiming
= 0.3125
tool
[ Tool ]: The tool.
- [ number ]: The movement speed fraction.
getMovementVelocity
tool:getMovementVelocity()
Client-Only
Returns the movement velocity of the player.
Arguments:tool
[ Tool ]: The tool.
- [ Vec3 ]: The player's velocity.
getOwner
tool:getOwner()
Returns the player that owns the tool.
Arguments:tool
[ Tool ]: The tool.
- [ Player ]: The tool's owner.
getPosition
tool:getPosition()
Client-Only
Returns the world position of the tool's owner.
Arguments:tool
[ Tool ]: The tool.
- [ Vec3 ]: The owner's world position.
getRelativeMoveDirection
tool:getRelativeMoveDirection()
Client-Only
Returns the relative movement direction of the player.
This is the direction the player wants to move based on movement input.
tool
[ Tool ]: The tool.
- [ Vec3 ]: The player's relative movement direction.
getTpBoneDir
tool:getTpBoneDir( bone )
Client-Only
Returns the world direction for a bone in the third person view animation skeleton.
Arguments:tool
[ Tool ]: The tool.bone
[ string ]: The bone name.
- [ Vec3 ]: The bone direction.
getTpBonePos
tool:getTpBonePos( bone )
Client-Only
Returns the world position for a bone in the third person view animation skeleton.
Arguments:tool
[ Tool ]: The tool.bone
[ string ]: The bone name.
- [ Vec3 ]: The bone position.
isCrouching
tool:isCrouching()
Client-Only
Returns whether the tool's owner is currently crouching.
Arguments:tool
[ Tool ]: The tool.
- [ bool ]: Whether the owner is crouching or not.
isEquipped
tool:isEquipped()
Client-Only
Returns whether the tool is equipped.
Arguments:tool
[ Tool ]: The tool.
- [ bool ]: Whether the tool is equipped or not.
isInFirstPersonView
tool:isInFirstPersonView()
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.
tool
[ Tool ]: The tool.
- [ bool ]: Whether the tool in first person view or not.
isLocal
tool:isLocal()
Client-Only
Returns whether the player holding the tool is the same as the Local Player
Arguments:tool
[ Tool ]: The tool.
- [ bool ]: Whether tool is local or not.
isOnGround
tool:isOnGround()
Client-Only
Returns whether the tool's owner is currently standing on the ground.
Arguments:tool
[ Tool ]: The tool.
- [ bool ]: Whether the owner is on the ground or not.
isSprinting
tool:isSprinting()
Client-Only
Returns whether the tool's owner is currently sprinting.
Arguments:tool
[ Tool ]: The tool.
- [ bool ]: Whether the owner is sprinting or not.
setBlockSprint
tool:setBlockSprint( state )
Client-Only
Sets whether the player is unable to sprint.
Sprinting is normally blocked when the player is attacking, blocking, aiming, etc.
tool
[ Tool ]: The tool.state
[ bool ]: Whether sprinting is blocked or not.
setCrossHairAlpha
tool:setCrossHairAlpha( alpha )
Client-Only
Sets the opacity of the crosshair.
An alpha value of 0 makes the crosshair transparent.
tool
[ Tool ]: The tool.alpha
[ number ]: The alpha value.
setDispersionFraction
tool:setDispersionFraction( fraction )
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.
Arguments:tool
[ Tool ]: The tool.fraction
[ number ]: The dispersion fraction.
setFpColor
tool:setFpColor( color )
Client-Only
Sets the tool's color in first person view.
Arguments:setFpRenderables
tool:setFpRenderables( renderables )
Client-Only
Sets the renderables (files containing model data) to be used for the character in first person view.
Arguments:tool
[ Tool ]: The tool.renderables
[ table ]: The table containing the renderable filepaths.
setInteractionTextSuppressed
tool:setInteractionTextSuppressed( state )
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.
tool
[ Tool ]: The tool.state
[ bool ]: Whether the text is suppressed or not.
setMovementAnimation
tool:setMovementAnimation( name, animation )
Client-Only
Sets the current third person view movement animation to be used by the tool.
Arguments:tool
[ Tool ]: The tool.name
[ string ]: The name.animation
[ string ]: The animation.
setMovementSlowDown
tool:setMovementSlowDown( slowdown )
Client-Only
Sets whether the player is slowed down.
This is similar to crouching and normally occurs when the player is aiming.
tool
[ Tool ]: The tool.slowdown
[ bool ]: Whether the player is slowed down or not.
setTpColor
tool:setTpColor( color )
Client-Only
Sets the tool's color in third person view.
Arguments:setTpRenderables
tool:setTpRenderables( renderables )
Client-Only
Sets the renderables (files containing model data) to be used for the character in third person view.
Arguments:tool
[ Tool ]: The tool.renderables
[ table ]: The table containing the renderable filepaths.
updateAnimation
tool:updateAnimation( name, time, weight )
Client-Only
Updates a third person view animation.
Arguments:tool
[ Tool ]: The tool.name
[ string ]: The animation name.time
[ number ]: The time.weight
[ number ]: The weight.
updateCamera
tool:updateCamera( distance, fov, offset, weight )
Client-Only
Updates the third person view camera for the tool.
Arguments:tool
[ Tool ]: The tool.distance
[ number ]: The distance.fov
[ number ]: The FOV.offset
[ Vec3 ]: The offset position.weight
[ number ]: The weight.
updateFpAnimation
tool:updateFpAnimation( name, time, weight=-1.0, looping )
Client-Only
Updates a first person view animation.
Arguments:tool
[ Tool ]: The tool.name
[ string ]: The animation name.time
[ number ]: The time.weight
[ number ]: The weight.looping
[ looping ]: Whether the animation is looping or not.
updateFpCamera
tool:updateFpCamera( fov, offset, weight, bobbing )
Client-Only
Updates the first person view camera for the tool.
Arguments:tool
[ Tool ]: The tool.fov
[ number ]: The FOV.offset
[ Vec3 ]: The offset position.weight
[ number ]: The weight.bobbing
[ number ]: The bobbing.
updateJoint
tool:updateJoint( name, rotation, weight )
Client-Only
Sets the rotation and weight for a bone in the animation skeleton.
Arguments:tool
[ Tool ]: The tool.name
[ string ]: The name.rotation
[ Vec3 ]: The rotation.weight
[ number ]: The weight.
updateMovementAnimation
tool:updateMovementAnimation( time, weight )
Client-Only
Updates the currently set third person view movement animation for the tool.
Arguments:tool
[ Tool ]: The tool.time
[ number ]: The time.weight
[ number ]: The weight.