Skip to content
MMOMinion edited this page Sep 29, 2013 · 14 revisions

Entity

  • The Entity is the central game-object. Entities are returned by the EntityList or by some functions like Player:GetTarget().
  • The Entity object is a lua table itself and has several entries itself.

Accessing an Entity

  • Here we are calling the EntityList to give us the nearest object on the mesh within a maxdistance of 20 which we can attack. The 'd' - debug print into the console the ID of that Entity as well as the whole table with all attributes.
  • Example:
local el = EntityList("nearest,onmesh,attackable,maxdistance=20")
if ( el ) then
   local i,e = next(el)
   if (i~=nil and e~=nil) then
      -- the 'd' command is a global command for printing out information into the console
      d("EntityID: ".. tostring(i).. " Entity : "..tostring(e))
   end  
end
  • The returned Entity e is a lua table and the i is the EntityID.
  • The Entity attributes can be accessed like this:
-- the 'd' command is a global command for printing out information into the console
d(e.hp.percent)
-- returns the health percentage value of this entity 'e'
d(e.targetid)
-- returns the targetID of this 'e'
d(e.distance)
-- returns the distance to this entity 'e'

Entity Attributes

name
Returns Entity Name (string).
id
Returns Entity ID (number).
type
Returns Entity ENTITYTYPE(number).
chartype
Returns Entity CHARACTERTYPE(number).
contentid
Returns an unique ID for that type of Entity (number).
hp
Returns a lua table which holds health values (table).
```lua -- the 'd' command is a global command for printing out information into the console local hptable = Player.hp d(hptable.current) -- current Health d(hptable.max) -- max Health d(hptable.percent) -- Health percent ```
mp
Returns a lua table which holds MP / TP values (table).
```lua -- the 'd' command is a global command for printing out information into the console local mptable = Player.mp d(mptable.current) -- current MP/TP d(mptable.max) -- max MP/TP d(mptable.percent) -- MP/TP percent ```
tp
Returns TP of that Entity (number).
pos
Returns a lua table which holds the position of that Entity (table).
-- the 'd' command is a global command for printing out information into the console
local postable = Player.pos
d(postable.x) -- x position
d(postable.y) -- y position
d(postable.z) -- z position
d(postable.h) -- current heading in radians
distance
Returns distance to that Entity (number).
job
Returns Entity JOB(number).
level
Returns Entity level (number).
aggro
Returns if Entity is aggro towards the player. (boolean).
attackable
Returns if the player can attack this Entity (includes a targetable check already) (boolean).
targetable
Returns if the player can target this Entity (boolean).
alive
Returns if the health of that Entity is larger 0 (boolean).
los
Returns if that Entity is in line of sight to the player (boolean).
cangather
Returns if the player can gather/harvest this Entity (boolean).
fateid
Returns the fateID this entity belongs to (number).
action
Returns an identifier of the action this Entity is currently doing (number).
lastaction
Returns an identifier of the last action this Entity was doing (number).
onmesh
Returns if this Entity is on the currently loaded navmesh (boolean).
hitradius
Returns a value that represents the "size" of this Entity, aka how FAT it is ;) (number).
buffs
Returns a lua table with all BUFFS & DEBUFFS of that Entity (number).
Clone this wiki locally