Skip to content
Urguwno edited this page Apr 2, 2015 · 2 revisions

Player

  • The Player object is in its core a normal Entity, but it has additional attributes as well as several functions you can call. This means all attributes an Entity has, the Player has also.

Accessing the Player object attributes

  • Example:
-- To print out the playername
d(Player.name)
-- print out the player position table
d(Player.pos)

Player Object Functions

  • Calling a function of the player object, example:
-- To get the current Target Entity and print out its name
local mytarget = Player:GetTarget()
if ( mytarget ) then d(mytarget.name) end

-- Using the build in navigation to move towards the mytarget we just got
if ( mytarget) then
   local pos = mytarget.pos
   Player:MoveTo(pos.x,pos.y,pos.z)
end

Player Functions

Player:GetTarget()
Returns an Entity of your target, returns 0 if you dont have one.
Player:SetTarget(EntityID)
Selects the Entity by its ID. Returns (boolean).
Player:Interact(EntityID)
Interacts with the Entity. Returns (boolean).
Player:SetFacing(X,Y,Z)
Turns your Player towards the position X,Y,Z. Returns (boolean).
Player:MoveTo(X,Y,Z,stoppingdistance)
Intelligently navigates the Player towards the position X,Y,Z and stops before reaching that position at **stoppingdistance**. This stoppingdistance argument is optional. This Function uses the navigation mesh to find its path towards the goal.
-- Returned Values:
Positive Values:
0 to 9999999: Successfully created a navigation path on the Navmesh towards the goal.
The number returned represents the remaining points along the path.

Negative Values:
-1 to -10: Different errorcodes, a path could not be created towards the goal.
-7: Distance to Goal is smaller than the passed stoppingdistance
-8: No Navmesh loaded / Navmesh is beeing build or not ready yet 
-10: The passed MoveTo coordinates are invalid
Player:Move(MOVEMENTSTATE)
Moves the Player into the direction of MOVEMENTSTATE. This function does NOT use any mesh navigation. Returns (boolean).
Player:Jump()
Jump baby!
Player:SetMovement(int)
Moves the character in a direction indicated by the arg.
Player:GetMovement()
Returns a lua table with 4 entries: left , right, forward, backward. Each having a value(bool).
Player:GetMovementState()
Returns movementstate.
Player:Stop()
Stops the Player from any active movement or navigation. Returns (boolean).
Player:IsMoving()
If the Player is currently moving in any direction. Returns (boolean).
Clone this wiki locally