sm.localPlayer

Local player represents the current character being controlled on the client's computer. This library can only be used on the client.

For more information about other players in the world, see sm.player.

Client-only

addRenderable

sm.localPlayer.addRenderable( renderable )

Adds a renderable (file containing model data) to be used for the local player in first person view.

Parameters:

Name Type Description
renderable string The renderable path.

getActiveItem

sm.localPlayer.getActiveItem(  )

Returns the item currently held by the local player.

Returns:

Type Description
Uuid The player's held item uuid.

getAimSensitivity

sm.localPlayer.getAimSensitivity(  )

Return the player aim sensitivity

Returns:

Type Description
number The aim sensitivity

getCarry

sm.localPlayer.getCarry(  )

Returns the carrying container of the local player.

Returns:

Type Description
Container The player's carry.

getCarryColor

sm.localPlayer.getCarryColor(  )

Returns the color of the shape the local player is carrying.

Returns:

Type Description
Color The color of the shape the local player is carrying.

getConstructionPlacement

sm.localPlayer.getConstructionPlacement(  )

Gets the world position and rotation of the local player's shape placement if it is not colliding. Otherwise nil is returned.

Returns:

Type Description
Vec3
Quat
World position and rotation.

getDirection

sm.localPlayer.getDirection(  )

Returns the direction the local player is aiming.

Returns:

Type Description
Vec3 The direction of the player's aim.

getFpAnimationInfo

sm.localPlayer.getFpAnimationInfo( name )

Returns general information for a first person view animation.

Parameters:

Name Type Description
name string The name.

Returns:

Type Description
table A table containing name, duration and looping.

getFpBonePos

sm.localPlayer.getFpBonePos( jointName )

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

Parameters:

Name Type Description
jointName string The joint name.

Returns:

Type Description
Vec3 The joint position.

getGarmentName

sm.localPlayer.getGarmentName( uuid )

Gets the title of the garment with the given uuid in the current language.

Parameters:

Name Type Description
uuid Uuid The garment.

Returns:

Type Description
string The title of the garment

getGarmentUpperCaseTitle

sm.localPlayer.getGarmentUpperCaseTitle( uuid )

Gets the UPPER CASE title of the garment with the given uuid in the current language.

Parameters:

Name Type Description
uuid Uuid The garment.

Returns:

Type Description
string The title of the garment

getHotbar

sm.localPlayer.getHotbar(  )

Returns the hotbar container of the player.

Returns:

Type Description
Container The player's hotbar.

getId

sm.localPlayer.getId(  )

Returns the unique player id of the local player.

Returns:

Type Description
integer The player's id.

getInventory

sm.localPlayer.getInventory(  )

Returns the inventory container of the local player.

Returns:

Type Description
Container The player's inventory.

getLatestRaycast

sm.localPlayer.getLatestRaycast(  )

Returns the latest interaction raycast result of the local player. This is the raycast that is constantly performed to detect interactable objects up to a range of 7.5.

Returns:

Type Description
bool True if raycast was successful
RaycastResult Raycast result data.

getMouseDelta

sm.localPlayer.getMouseDelta(  )

Returns delta positions of mouse

Returns:

Type Description
number Delta X
number Delta Y

getOwnedLift

sm.localPlayer.getOwnedLift(  )

Returns the Lift of the local player.

Returns:

Type Description
Lift The player's lift.

getPlayer

sm.localPlayer.getPlayer(  )

Returns the player object of the local player.

Returns:

Type Description
Player The player object.

getPosition

sm.localPlayer.getPosition(  )

Deprecated: Use Character.worldPosition or Character.getWorldPosition

Returns the world position of the local player.

Returns:

Type Description
Vec3 The player's world position.

getRaycast

sm.localPlayer.getRaycast( range, origin, direction )

Performs a raycast relative to the local player's perspective.

Parameters:

Name Type Description
range number The maximum range.
origin (optional) Vec3 The start position. (Defaults to sm.localPlayer.getRaycastStart)
direction (optional) Vec3 The direction. (Defaults to sm.localPlayer.getDirection)

Returns:

Type Description
bool True if raycast was successful
RaycastResult Raycast result data.

getRaycastStart

sm.localPlayer.getRaycastStart(  )

Returns the start position of the local player's raycast. The position depends on the camera's position, and whether it's in first- of third-person.

Returns:

Type Description
Vec3 The start position of the raycast.

getRight

sm.localPlayer.getRight(  )

Returns the right-vector perpendicular to the local player's aim.

Returns:

Type Description
Vec3 The right-vector of the player's aim.

getSelectedHotbarSlot

sm.localPlayer.getSelectedHotbarSlot(  )

Returns the local player's selected slot.

Returns:

Type Description
integer The player's selected slot.

getUp

sm.localPlayer.getUp(  )

Returns the up-vector perpendicular to the local player's aim.

Returns:

Type Description
Vec3 The up-vector of the player's aim.

getWantsSprint

sm.localPlayer.getWantsSprint(  )

Checks if local player wants to sprint (pressing the sprint key).

Returns:

Type Description
boolean Whether the player is holding the sprint key.

getWorld

sm.localPlayer.getWorld(  )

Gets the world the local player's character is in, if any, otherwise nil.

Returns:

Type Description
World The world the local player is in, if any.

grantQuestItem

sm.localPlayer.grantQuestItem( uid )

Visibility: Hidden

Unlocks a cosmetic with the given uuid for the player. Requires survival mode, non modified core files and no active mods to function.

Parameters:

Name Type Description
uid Uuid The uuid of the unlocked cosmetic.

isGarmentUnlocked

sm.localPlayer.isGarmentUnlocked( uuid )

Check if the garment has been granted to the local player.

Parameters:

Name Type Description
uuid Uuid The garment.

Returns:

Type Description
boolean Returns true if the garment is unlocked.

isInFirstPersonView

sm.localPlayer.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.

Returns:

Type Description
boolean Whether the player is in first person view.

removeRenderable

sm.localPlayer.removeRenderable( renderable )

Removes a renderable (file containing model data) that was used for the local player in first person view.

Parameters:

Name Type Description
renderable string The renderable path.

secondaryInteractBusy

sm.localPlayer.secondaryInteractBusy(  )

Returns if the currently equipped tool consumes the secondary interaction, such as aiming with the spudgun.

Returns:

Type Description
boolean True if the tool consumes the secondary interaction.

setBlockSprinting

sm.localPlayer.setBlockSprinting( blockSprinting )

Stops the local player from sprinting.

Parameters:

Name Type Description
blockSprinting boolean Sets whether sprinting is blocked.

setDirection

sm.localPlayer.setDirection( direction )

Sets the direction of where the player is viewing or aiming. Intended to be used when the controls have been locked. (See sm.localPlayer.setLockedControls)

Parameters:

Name Type Description
direction Vec3 The world direction.

setLockedControls

sm.localPlayer.setLockedControls( locked )

Sets whether the player's in-game controls are locked.

Parameters:

Name Type Description
locked boolean The lock state.

updateFpAnimation

sm.localPlayer.updateFpAnimation( name, time, weight, looping )

Updates a first person view animation.

Parameters:

Name Type Description
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)