Module ...

A game entity An entity is anything that goes on a map, terrain features, objects, monsters, player, ... Usually there is no need to use it directly, and it is betetr to use specific engine.Grid, engine.Actor or engine.Object classes. Most modules will want to subclass those anyway to add new comportments

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:init (t, no_default) Initialize an entity Any subclass MUST call this constructor
_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:removed () Call when the entity is actually removed from existance This helps ensuring uniqueness of uniques.
_M:resolve (t, last) 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: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: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: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)
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:

Valid XHTML 1.0!