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.
Functions:
sm.localPlayer.addRenderable(renderable)
Client only
Adds a renderable (file containing model data) to be used for the local player in first person view.
Parameters:
| Type | Name | Description |
|---|---|---|
| string | renderable | The renderable path. |
sm.localPlayer.getActiveItem()
Client only
Returns the item currently held by the local player.
Returns:
| Type | Description |
|---|---|
| Uuid | The player's held item uuid. |
sm.localPlayer.getAimSensitivity()
Client only
Return the player aim sensitivity
Returns:
| Type | Description |
|---|---|
| number | The aim sensitivity |
sm.localPlayer.getCarry()
Client only
Returns the carrying container of the local player.
Returns:
| Type | Description |
|---|---|
| Container | The player's carry. |
sm.localPlayer.getCarryColor()
Client only
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. |
sm.localPlayer.getConstructionPlacement()
Client only
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. |
sm.localPlayer.getDirection()
Client only
Returns the direction the local player is aiming.
Returns:
| Type | Description |
|---|---|
| Vec3 | The direction of the player's aim. |
sm.localPlayer.getFpAnimationInfo(name)
Client only
Returns general information for a first person view animation.
Parameters:
| Type | Name | Description |
|---|---|---|
| string | name | The name. |
Returns:
| Type | Description |
|---|---|
| table | A table containing name, duration and looping. |
sm.localPlayer.getFpBonePos(jointName)
Client only
Returns the world position for a bone in the first person view animation skeleton.
Parameters:
| Type | Name | Description |
|---|---|---|
| string | jointName | The joint name. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The joint position. |
sm.localPlayer.getGarmentName(uuid)
Client only
Gets the title of the garment with the given uuid in the current language.
Parameters:
| Type | Name | Description |
|---|---|---|
| Uuid | uuid | The garment. |
Returns:
| Type | Description |
|---|---|
| string | The title of the garment |
sm.localPlayer.getGarmentUpperCaseTitle(uuid)
Client only
Gets the UPPER CASE title of the garment with the given uuid in the current language.
Parameters:
| Type | Name | Description |
|---|---|---|
| Uuid | uuid | The garment. |
Returns:
| Type | Description |
|---|---|
| string | The title of the garment |
sm.localPlayer.getHotbar()
Client only
Returns the hotbar container of the player.
Returns:
| Type | Description |
|---|---|
| Container | The player's hotbar. |
sm.localPlayer.getId()
Client only
Returns the unique player id of the local player.
Returns:
| Type | Description |
|---|---|
| integer | The player's id. |
sm.localPlayer.getInventory()
Client only
Returns the inventory container of the local player.
Returns:
| Type | Description |
|---|---|
| Container | The player's inventory. |
sm.localPlayer.getLatestRaycast()
Client only
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, RaycastResult | True if raycast was successful; Raycast result data. |
sm.localPlayer.getMouseDelta()
Client only
Returns delta positions of mouse
Returns:
| Type | Description |
|---|---|
| number,number | Delta X; Delta Y |
sm.localPlayer.getOwnedLift()
Client only
Returns the Lift of the local player.
Returns:
| Type | Description |
|---|---|
| Lift | The player's lift. |
sm.localPlayer.getPlayer()
Client only
Returns the player object of the local player.
Returns:
| Type | Description |
|---|---|
| Player | The player object. |
sm.localPlayer.getPosition()
Deprecated:
Client only
Returns the world position of the local player.
Returns:
| Type | Description |
|---|---|
| Vec3 | The player's world position. |
sm.localPlayer.getRaycast(range, origin?, direction?)
Client only
Performs a raycast relative to the local player's perspective.
Parameters:
| Type | Name | Description |
|---|---|---|
| number | range | The maximum range. |
| Vec3 | origin? | The start position. (Defaults to sm.localPlayer.getRaycastStart) |
| Vec3 | direction? | The direction. (Defaults to sm.localPlayer.getDirection) |
Returns:
| Type | Description |
|---|---|
| bool, RaycastResult | True if raycast was successful; Raycast result data. |
sm.localPlayer.getRaycastStart()
Client only
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. |
sm.localPlayer.getRight()
Client only
Returns the right-vector perpendicular to the local player's aim.
Returns:
| Type | Description |
|---|---|
| Vec3 | The right-vector of the player's aim. |
sm.localPlayer.getSelectedHotbarSlot()
Client only
Returns the local player's selected slot.
Returns:
| Type | Description |
|---|---|
| integer | The player's selected slot. |
sm.localPlayer.getUp()
Client only
Returns the up-vector perpendicular to the local player's aim.
Returns:
| Type | Description |
|---|---|
| Vec3 | The up-vector of the player's aim. |
sm.localPlayer.getWantsSprint()
Client only
Checks if local player wants to sprint (pressing the sprint key).
Returns:
| Type | Description |
|---|---|
| boolean | Whether the player is holding the sprint key. |
sm.localPlayer.getWorld()
Client only
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. |
sm.localPlayer.grantQuestItem(uid)
Client only
Unlocks a cosmetic with the given uuid for the player. Requires survival mode, non modified core files and no active mods to function.
Parameters:
| Type | Name | Description |
|---|---|---|
| Uuid | uid | The uuid of the unlocked cosmetic. |
sm.localPlayer.isGarmentUnlocked(uuid)
Client only
Check if the garment has been granted to the local player.
Parameters:
| Type | Name | Description |
|---|---|---|
| Uuid | uuid | The garment. |
Returns:
| Type | Description |
|---|---|
| boolean | Returns true if the garment is unlocked. |
sm.localPlayer.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.
Returns:
| Type | Description |
|---|---|
| boolean | Whether the player is in first person view. |
sm.localPlayer.removeRenderable(renderable)
Client only
Removes a renderable (file containing model data) that was used for the local player in first person view.
Parameters:
| Type | Name | Description |
|---|---|---|
| string | renderable | The renderable path. |
sm.localPlayer.secondaryInteractBusy()
Client only
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. |
sm.localPlayer.setBlockSprinting(blockSprinting)
Client only
Stops the local player from sprinting.
Parameters:
| Type | Name | Description |
|---|---|---|
| boolean | blockSprinting | Sets whether sprinting is blocked. |
sm.localPlayer.setDirection(direction)
Client only
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:
| Type | Name | Description |
|---|---|---|
| Vec3 | direction | The world direction. |
sm.localPlayer.setLockedControls(locked)
Client only
Sets whether the player's in-game controls are locked.
Parameters:
| Type | Name | Description |
|---|---|---|
| boolean | locked | The lock state. |
sm.localPlayer.updateFpAnimation(name, time, weight?, looping?)
Client only
Updates a first person view animation.
Parameters:
| Type | Name | Description |
|---|---|---|
| string | name | The name. |
| number | time | The time. |
| number | weight? | The weight. (Defaults to -1.0) |
| boolean | looping? | The looping. (Defaults to false) |