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:

  • addRenderable
  • getActiveItem
  • getAimSensitivity
  • getCarry
  • getCarryColor
  • getConstructionPlacement
  • getDirection
  • getFpAnimationInfo
  • getFpBonePos
  • getGarmentName
  • getGarmentUpperCaseTitle
  • getHotbar
  • getId
  • getInventory
  • getLatestRaycast
  • getMouseDelta
  • getOwnedLift
  • getPlayer
  • getPosition
  • getRaycast
  • getRaycastStart
  • getRight
  • getSelectedHotbarSlot
  • getUp
  • getWantsSprint
  • getWorld
  • grantQuestItem
  • isGarmentUnlocked
  • isInFirstPersonView
  • removeRenderable
  • secondaryInteractBusy
  • setBlockSprinting
  • setDirection
  • setLockedControls
  • updateFpAnimation

  • 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:

    TypeNameDescription
    stringrenderableThe renderable path.

    sm.localPlayer.getActiveItem()

    Client only

    Returns the item currently held by the local player.

    Returns:

    TypeDescription
    UuidThe player's held item uuid.

    sm.localPlayer.getAimSensitivity()

    Client only

    Return the player aim sensitivity

    Returns:

    TypeDescription
    numberThe aim sensitivity

    sm.localPlayer.getCarry()

    Client only

    Returns the carrying container of the local player.

    Returns:

    TypeDescription
    ContainerThe player's carry.

    sm.localPlayer.getCarryColor()

    Client only

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

    Returns:

    TypeDescription
    ColorThe 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:

    TypeDescription
    Vec3, QuatWorld position and rotation.

    sm.localPlayer.getDirection()

    Client only

    Returns the direction the local player is aiming.

    Returns:

    TypeDescription
    Vec3The direction of the player's aim.

    sm.localPlayer.getFpAnimationInfo(name)

    Client only

    Returns general information for a first person view animation.

    Parameters:

    TypeNameDescription
    stringnameThe name.

    Returns:

    TypeDescription
    tableA 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:

    TypeNameDescription
    stringjointNameThe joint name.

    Returns:

    TypeDescription
    Vec3The joint position.

    sm.localPlayer.getGarmentName(uuid)

    Client only

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

    Parameters:

    TypeNameDescription
    UuiduuidThe garment.

    Returns:

    TypeDescription
    stringThe 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:

    TypeNameDescription
    UuiduuidThe garment.

    Returns:

    TypeDescription
    stringThe title of the garment

    sm.localPlayer.getHotbar()

    Client only

    Returns the hotbar container of the player.

    Returns:

    TypeDescription
    ContainerThe player's hotbar.

    sm.localPlayer.getId()

    Client only

    Returns the unique player id of the local player.

    Returns:

    TypeDescription
    integerThe player's id.

    sm.localPlayer.getInventory()

    Client only

    Returns the inventory container of the local player.

    Returns:

    TypeDescription
    ContainerThe 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:

    TypeDescription
    bool, RaycastResultTrue if raycast was successful; Raycast result data.

    sm.localPlayer.getMouseDelta()

    Client only

    Returns delta positions of mouse

    Returns:

    TypeDescription
    number,numberDelta X; Delta Y

    sm.localPlayer.getOwnedLift()

    Client only

    Returns the Lift of the local player.

    Returns:

    TypeDescription
    LiftThe player's lift.

    sm.localPlayer.getPlayer()

    Client only

    Returns the player object of the local player.

    Returns:

    TypeDescription
    PlayerThe player object.

    sm.localPlayer.getPosition()

    Deprecated:

    Use Character.worldPosition or Character.getWorldPosition

    Client only

    Returns the world position of the local player.

    Returns:

    TypeDescription
    Vec3The player's world position.

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

    Client only

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

    Parameters:

    TypeNameDescription
    numberrangeThe maximum range.
    Vec3origin?The start position. (Defaults to sm.localPlayer.getRaycastStart)
    Vec3direction?The direction. (Defaults to sm.localPlayer.getDirection)

    Returns:

    TypeDescription
    bool, RaycastResultTrue 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:

    TypeDescription
    Vec3The start position of the raycast.

    sm.localPlayer.getRight()

    Client only

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

    Returns:

    TypeDescription
    Vec3The right-vector of the player's aim.

    sm.localPlayer.getSelectedHotbarSlot()

    Client only

    Returns the local player's selected slot.

    Returns:

    TypeDescription
    integerThe player's selected slot.

    sm.localPlayer.getUp()

    Client only

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

    Returns:

    TypeDescription
    Vec3The up-vector of the player's aim.

    sm.localPlayer.getWantsSprint()

    Client only

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

    Returns:

    TypeDescription
    booleanWhether 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:

    TypeDescription
    WorldThe 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:

    TypeNameDescription
    UuiduidThe uuid of the unlocked cosmetic.

    sm.localPlayer.isGarmentUnlocked(uuid)

    Client only

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

    Parameters:

    TypeNameDescription
    UuiduuidThe garment.

    Returns:

    TypeDescription
    booleanReturns 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:

    TypeDescription
    booleanWhether 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:

    TypeNameDescription
    stringrenderableThe renderable path.

    sm.localPlayer.secondaryInteractBusy()

    Client only

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

    Returns:

    TypeDescription
    booleanTrue if the tool consumes the secondary interaction.

    sm.localPlayer.setBlockSprinting(blockSprinting)

    Client only

    Stops the local player from sprinting.

    Parameters:

    TypeNameDescription
    booleanblockSprintingSets 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:

    TypeNameDescription
    Vec3directionThe world direction.

    sm.localPlayer.setLockedControls(locked)

    Client only

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

    Parameters:

    TypeNameDescription
    booleanlockedThe lock state.

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

    Client only

    Updates a first person view animation.

    Parameters:

    TypeNameDescription
    stringnameThe name.
    numbertimeThe time.
    numberweight?The weight. (Defaults to -1.0)
    booleanlooping?The looping. (Defaults to false)