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 (src) If we are cloned we need a new uid
_M:getDisplayString (tstr) Get a string that will display in text the texture of this entity
_M:getEntityFinalSurface (tiles, w, h) Get the entity image as an sdl surface and texture for the given tiles and size
_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, loaded) 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
_M:toScreen (tiles, x, y, w, h) Displays an entity somewhere on screen, outside the map


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 (src)
If we are cloned we need a new uid

Parameters

  • src:
_M:getDisplayString (tstr)
Get a string that will display in text the texture of this entity

Parameters

  • tstr:
_M:getEntityFinalSurface (tiles, w, h)
Get the entity image as an sdl surface and texture for the given tiles and size

Parameters

  • tiles: a Tiles instance that will handle the tiles (usualy pass it the current Map.tiles)
  • w: the width
  • h: the height

Return value:

the sdl surface and the texture
_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, loaded)
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
  • loaded:

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:
_M:toScreen (tiles, x, y, w, h)
Displays an entity somewhere on screen, outside the map

Parameters

  • tiles: a Tiles instance that will handle the tiles (usualy pass it the current Map.tiles, it will if this is null)
  • x:
  • y:
  • w: the width
  • h: the height

Return value:

the sdl surface and the texture

Valid XHTML 1.0!