Skip to content
Sihoiba edited this page Jul 19, 2023 · 8 revisions

Callbacks are Lua functions that are automatically called by the engine when some conditions are met. They can also be manually called with:

world:lua_callback( entity, "callback_name" )

Be careful: some callbacks for different kind of blueprints can the same name but different arguments.

Callbacks for all entities

on_create

Called when the entity is created. Used to initialize the entity.

function( self )

on_attach

Called when the item is attached to something

function( self, parent )

Parameters:

  • parent: what it’s attached to

on_detach

Called when the item is detached from something

function( self, parent )

Parameters:

  • parent: what it’s detached from

on_enter

Called when an entity enters the same spot. Used for elevators, portals, item acquired automatically (backpack, health orb...)

function( self, entity )

on_proximity

Called when an entity is on an adjacent tile.

	function(self,entity,inside)

Callbacks for worlds

Worlds are registered with "register_world" instead of "register_blueprint"

on_setup

on_next

on_load

on_init

on_end

on_stats

on_entity

Callback for events/levels

on_update

on_cleared

Called when the level is cleared (when the level title turns blue)

function ( self, level )

is_cleared

function ( self )

on_move

Called when a being moves

function ( self, who, position )

on_enter_level

function ( self )

on_create_entity

function ( level, entity )

on_enter_level

Applies to: events, …

function ( self, level, entity, reenter )

Callback for challenges

on_create_player

function( self, player )

on_mortem

function( self, player, win )

can_pick_trait

function( self, player, trait_id )

Callback for beings

on_enter_level

Called when the entity enters a level (only useful for the player?)

function ( self, entity, reenter )

Parameters:

  • entity: the entity that enters
  • reenter: boolean

on_wait

Called when the user waits

function ( self, entity )

Parameters:

  • entity: the entity that waits

on_aim

Called when the user aims

function ( self, entity, target, weapon )

Parameters:

  • entity: the user
  • target: the targeted being
  • weapon: the weapon the perk is on (?)

on_receive_damage

Called when the being receives damage

 function ( self, source, weapon, amount )

Parameters:

  • source: the unit that deals the damage?
  • weapon: origin of the damage
  • amount: health lost

on_incoming_damage

Called when the entity is about to get damage. Useful to modify resistances before the amount of lost HP is computed

function ( self, entity, source )

on_activate

Called when an action is performed on the being? (like hacking for bots)

function( self, who, level, param )

Parameters:

  • who: who does the action
  • level: current level
  • param: ?

on_pre_command

Called before a command is performed

function ( self, entity, command, target )

on_post_command

Called after a command is performed

function ( self, actor, cmt, target, time )

Parameters:

  • actor: entity doing the action
  • cmt: the command
  • target: target of the command
  • time: duration of the command?

on_pickup

Called when the being picks up something

function( self, what )

Parameters:

  • what: what is picked up

on_spot

Called when the units see something for the first time

function( self, what )

Parameters:

  • what: what is seen

on_action

Called when the entity can act

function ( self, entity, time_passed, last )

Parameters:

  • time_passed: in-game time since the last call
  • entity: the entity this object is attached to
  • last: ?

on_die

Called when the entity dies

function( self, killer, current, weapon )

Parameters:

  • killer: the killer of the entity
  • current: ?
  • weapon: the killing weapon

on_move

Called when the unit moves

function ( self, entity )

Parameters:

  • entity: ?

on_pre_move

function ( self, user )

on_rearm

Called when the entity swaps weapons

function(self,entity,wpn,wpn_next)

Parameters:

  • entity: the swapping entity
  • wpn: previous weapon
  • wpn_next: next weapon

on_kill

Called when the entity kills something

function ( self, entity, target, weapon, gibbed, coord )

Parameters:

  • entity: killer
  • target: killed
  • weapon: weapon used for killing
  • gibbed: boolean
  • coord: of the killed?

on_damage

function ( unused, weapon, who, amount, source )

Parameters: ...

on_holster

Called when the weapon is swapped out

function(self)

on_activate

Called when the weapon is equipped?

function( self, entity )

Parameters:

  • entity: the entity that uses the weapon

on_damage

Called when it deals damage

function ( weapon, who, amount, source )

Parameters:

  • who: the entity that is damaged
  • amount: the amount of health dealt
  • source: ?

on_area_damage

Called when it deals damage over an area

function ( self, level, c, damage, distance )

Callback for the player only

on_adrenaline

on_stealth

on_smoke_screen

Callback for beings with AI

on_attacked

Called when the entity is attacked

on_attacked = "aitk.on_attacked",

on_action

Called when the entity can act

on_action   = "aitk.standard_ai",

on_noise

Called when the entity hears a noise

on_noise    = "aitk.on_noise",

on_timer

Unclear when it’s called

function ( self, first )

Parameters:

  • first: ?

Callbacks for traits

on_activate

Called when the skill is bought

function(self,entity)

on_use

Called when an active skill is used

function ( self, entity, level, target )

Callbacks for item only

on_dropped

Only used for the frozen heart

function( self, who )

Parameters:

  • who: the dropper

on_picked_up

Only used for the frozen heart

function( self, who )

Parameters:

  • who: the picker

on_use

Called when a consumable is used

function(self,entity)

on_level_up

Called when a unique level up.

function ( self, item )

Parameters:

  • item: ?

can_drop

Called when the entity wants to drop the item

function ( self, owner, confirm, pickup )

can_pickup

Called when the entity wants to pick up an item

function( self, player, item )

Callbacks that need to be sorted...

on_activate_other

on_callback

on_terminal_refresh