CorsixTH Lua Documentation

Entity Class

Abstraction for visible gameplay things which sit somewhere on the map.

Declared on: line 21 of Lua/entity.lua.
Subclasses: Humanoid, Litter, Object

Method Index

Member Index

function Entity:Entity(animation)

Parameters:

NameTypeDescription
animation ? ?

Declared on: line 26 of Lua/entity.lua.

function Entity:_tick()

Inner tick function that will skip every other tick when slow_animation is set.

Declared on: line 128 of Lua/entity.lua.

function Entity:afterLoad(old, new)

Stub to be extended in subclasses, if needed.

Parameters:

NameTypeDescription
old ? ?
new ? ?

Declared on: line 272 of Lua/entity.lua.

function Entity:clearDynamicInfo()

Completely clears the dynamic info.

Declared on: line 267 of Lua/entity.lua.

function Entity:getDrawingLayer()

Returns the drawing layer for this particular entity. Should be overriden in derived classes. The drawing layer specifies the order in which object are drawn in a tile (the object with the smallest layer is drawn first). Litter should have layer 0, side objects to the north layer 1, side objects to the west layer 2, normal objects should have layers between 3 and 7, east side object should have layer 8 and south side objects layer 9.

Declared on: line 282 of Lua/entity.lua.

function Entity:getDynamicInfo()

Returns a table of hover info about an object.

Declared on: line 249 of Lua/entity.lua.

function Entity:notifyNewObject(id)

Parameters:

NameTypeDescription
id ? ?

Declared on: line 243 of Lua/entity.lua.

function Entity:onDestroy()

Function which is called when the entity is to be permanently removed from the world.

Declared on: line 223 of Lua/entity.lua.

function Entity:playSound(name)

This plays a sound "at" the entity, meaning the sound will not be played if the entity is off-screen, and the volume will be quieter the further the entity is from the center of the screen. If this is not what you want then use UI:playSound instead.

Parameters:

NameTypeDescription
name string or integer The filename or ordinal of the sound to play.

Declared on: line 34 of Lua/entity.lua.

function Entity:setAnimation(animation, flags)

Set which animation is used to give the entity a visual appearance.

Until an entity is given an animation, it is invisible to the player. Note that some "animations" consist of a single frame, and hence the term animation is used both to mean things which are animated and things which are static.

Parameters:

NameTypeDescription
animation integer The ordinal into the main animation set
flags integer A combination of zero or more drawing flags to control the use of alternative palettes, transparency, and other similar settings. See `THDF_` values in `th_gfx.h` for the possible bit values.

Declared on: line 45 of Lua/entity.lua.

function Entity:setDynamicInfo(type, value)

Sets a piece of Dynamic_info. type could be 'text', 'progress' or 'dividers'

Parameters:

NameTypeDescription
type ? ?
value ? ?

Declared on: line 254 of Lua/entity.lua.

function Entity:setLayer(layer, id)

Set which parts of the animation to be displayed.

Each animation is made up of 13 layers, and generally has several different options for each layer. In the animation viewer tool, multiple options can be toggled on for each layer, however here only one option may be selected per layer.

Parameters:

NameTypeDescription
layer integer The layer to set (1 through 13).
id integer The option to display for the given layer.

Declared on: line 173 of Lua/entity.lua.

function Entity:setMood(mood_name, activate)

Parameters:

NameTypeDescription
mood_name ? ?
activate ? ?

Declared on: line 246 of Lua/entity.lua.

function Entity:setMoodInfo(new_mood)

Used to set a mood icon over the entity.

Parameters:

NameTypeDescription
new_mood ? ?

Declared on: line 206 of Lua/entity.lua.

function Entity:setPosition(x, y)

Set the pixel position of the entity within the current tile.

Parameters:

NameTypeDescription
x integer The 0-based X pixel offset from the default position.
y integer The 0-based Y pixel offset from the default position.

Declared on: line 95 of Lua/entity.lua.

function Entity:setSpeed(x, y)

Set the rate at which the entity pixel position changes

Parameters:

NameTypeDescription
x integer The X component of the speed in pixels per tick.
y integer The Y component of the speed in pixels per tick.

Declared on: line 104 of Lua/entity.lua.

function Entity:setTile(x, y)

Set the map tile which the entity is on.

Parameters:

NameTypeDescription
x integer The 1-based X co-ordinate of the tile.
y integer The 1-based Y co-ordinate of the tile.

Declared on: line 68 of Lua/entity.lua.

function Entity:setTilePositionSpeed(tx, ty, px, py, sx, sy)

Combined form of `setTile`, `setPosition`, and `setSpeed`

Parameters:

NameTypeDescription
tx integer The 1-based X co-ordinate of the tile.
ty integer The 1-based Y co-ordinate of the tile.
px integer The 0-based X pixel offset from the default position.
py integer The 0-based Y pixel offset from the default position.
sx integer The X component of the speed in pixels per tick.
sy integer The Y component of the speed in pixels per tick.

Declared on: line 113 of Lua/entity.lua.

function Entity:setTimer(tick_count, f)

Register a function (related to the entity) to be called at a later time.

Each `Entity` can have a single timer associated with it, and due to this limit of one, it is almost always the case that the currently active humanoid action is the only thing wich calls `setTimer`. If self.slow_animation is set then all timers will be doubled as animation length will be doubled.

Parameters:

NameTypeDescription
tick_count integer If 0, then `f` will be called during the entity's next `tick`. If 1, then `f` will be called one tick after that, and so on.
f function Function which takes a single argument (the entity).

Declared on: line 187 of Lua/entity.lua.

function Entity:tick()

Function which is called once every tick, where a tick is the smallest unit of time in the game engine. Typically used to advance animations and similar recurring or long-duration tasks.

Declared on: line 141 of Lua/entity.lua.

function Entity:tickDay()

Function which is called at the end of each ingame day. Should be used to implement behaviours which happen regularly, but not as frequently as to need them in `tick`.

Declared on: line 237 of Lua/entity.lua.

Page generated on Sat Feb 07, 2015 at 18:38:28 by LDocGen.