Module engine.Entity

Functions

_M:added () Call when the entity is actually added to a level/whatever This helps ensuring uniqueness of uniques
_M:changeUid (newuid) Change the entity's uid *WARNING*: ONLY DO THIS IF YOU KNOW WHAT YOU ARE DOING!.
_M:check (prop, ...) Check for an entity's property If not a function it returns it directly, otherwise it calls the function with the extra parameters
_M:cloned () If we are cloned we need a new uid
_M:getMapObjects (tiles, mos, z) Get all "map objects" representing this entity Do not touch unless you *KNOW* what you are doing.
You do *NOT* need this, this is used by the engine.Map class automatically.
*DO NOT TOUCH!!!*
_M:init (t, no_default) Initialize an entity Any subclass MUST call this constructor
_M:invalidateAllMO () Invalidates the whole MO repository
_M:loadList (file, no_default, res, mod) Loads a list of entities from a definition file
_M:loaded () If we are loaded we need a new uid
_M:makeMapObject (tiles, idx) Create the "map object" representing this entity Do not touch unless you *KNOW* what you are doing.
You do *NOT* need this, this is used by the engine.Map class automatically.
*DO NOT TOUCH!!!*
_M:removed () Call when the entity is actually removed from existance This helps ensuring uniqueness of uniques.
_M:resolve (t, last, on_entity) Resolves an entity This is called when generatingthe final clones of an entity for use in a level.
This can be used to make random enchants on objects, random properties on actors, ...
by default this only looks for properties with a table value containing a __resolver field


Functions

_M:added ()
Call when the entity is actually added to a level/whatever This helps ensuring uniqueness of uniques
_M:changeUid (newuid)
Change the entity's uid *WARNING*: ONLY DO THIS IF YOU KNOW WHAT YOU ARE DOING!. YOU DO NOT !

Parameters

  • newuid:
_M:check (prop, ...)
Check for an entity's property If not a function it returns it directly, otherwise it calls the function with the extra parameters

Parameters

  • prop: the property name to check
  • ...:
_M:cloned ()
If we are cloned we need a new uid
_M:getMapObjects (tiles, mos, z)
Get all "map objects" representing this entity Do not touch unless you *KNOW* what you are doing.
You do *NOT* need this, this is used by the engine.Map class automatically.
*DO NOT TOUCH!!!*

Parameters

  • tiles:
  • mos:
  • z:
_M:init (t, no_default)
Initialize an entity Any subclass MUST call this constructor

Parameters

  • t: a table defining the basic properties of the entity
  • no_default:

Usage:

Entity.new{display='#', color_r=255, color_g=255, color_b=255}
_M:invalidateAllMO ()
Invalidates the whole MO repository
_M:loadList (file, no_default, res, mod)
Loads a list of entities from a definition file

Parameters

  • file: the file to load from
  • no_default: if true then no default values will be assigned
  • res: the table to load into, defaults to a new one
  • mod: an optional function to which will be passed each entity as they are created. Can be used to adjust some values on the fly

Usage:

MyEntityClass:loadList("/data/my_entities_def.lua")
_M:loaded ()
If we are loaded we need a new uid
_M:makeMapObject (tiles, idx)
Create the "map object" representing this entity Do not touch unless you *KNOW* what you are doing.
You do *NOT* need this, this is used by the engine.Map class automatically.
*DO NOT TOUCH!!!*

Parameters

  • tiles:
  • idx:
_M:removed ()
Call when the entity is actually removed from existance This helps ensuring uniqueness of uniques. This recursively remvoes inventories too, if you need anythign special, overload this
_M:resolve (t, last, on_entity)
Resolves an entity This is called when generatingthe final clones of an entity for use in a level.
This can be used to make random enchants on objects, random properties on actors, ...
by default this only looks for properties with a table value containing a __resolver field

Parameters

  • t:
  • last:
  • on_entity:

Valid XHTML 1.0!