Skip to content
MMOMinion edited this page Sep 28, 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))  
      local i,e = next(el)  
   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).
Clone this wiki locally