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
  • getDirection
  • getFpAnimationInfo
  • getFpBonePos
  • getHotbar
  • getId
  • getInventory
  • getMouseDelta
  • getOwnedLift
  • getPlayer
  • getPosition
  • getRaycast
  • getRaycastStart
  • getRight
  • getSelectedHotbarSlot
  • getUp
  • isGarmentUnlocked
  • isInFirstPersonView
  • removeRenderable
  • 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.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.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.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=nil, direction=nil)

    Client only

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

    Parameters:

    TypeNameDescription
    numberrangeThe maximum range.
    Vec3origin=nilThe start position. (Defaults to sm.localPlayer.getRaycastStart)
    Vec3direction=nilThe 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.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.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=-1.0, looping=false)

    Client only

    Updates a first person view animation.

    Parameters:

    TypeNameDescription
    stringnameThe name.
    numbertimeThe time.
    numberweight=-1.0The weight.
    booleanlooping=falseThe looping.