🔄Callbacks
Callbacks for lua
Scripts should return a table with the following functions. If the table contains one of the functions below, it will be registered as a callback and will be called at the appropriate time.
OnScriptsLoaded(): nil
nil
Called after all scripts are loaded.
OnDraw(): nil
nil
Called when the game is drawing. Works only in the game. Recommended to use for drawing only.
OnFrame(): nil
nil
The same as OnDraw, but called in the menu too.
OnUpdate(): nil
nil
Called every game update. Works only in the game. Recommended to use for logic.
OnPreHumanizer(): nil
nil
TODO
OnUpdateEx(): nil
nil
Called every game update. Same as OnUpdate but as well called in the menu. Recommended to use for logic.
OnEntityCreate(entity: CEntity
): nil
CEntity
): nil
Called when a new entity is created.
OnEntityDestroy(entity: CEntity
): nil
CEntity
): nil
Called when an entity is destroyed.
Called when a modifier is created.
Called when a modifier is destroyed.
Called when a modifier is updated/refreshed.
OnEntityHurt(data: {source:CEntity|nil, target:CEntity|nil, ability:CAbility|nil, damage:number}
): nil
{source:CEntity|nil, target:CEntity|nil, ability:CAbility|nil, damage:number}
): nil
This callback is called only in unsafe mode.
Called when an entity is hurt.
OnEntityKilled(data: {source:CEntity|nil, target:CEntity|nil, ability:CAbility|nil}
): nil
{source:CEntity|nil, target:CEntity|nil, ability:CAbility|nil}
): nil
This callback is called only in unsafe mode.
Called when an entity is killed.
OnFireEventClient(data: {name:string, event:Event}
): nil
{name:string, event:Event}
): nil
This callback is called only in unsafe mode.
Called when a game event is fired.
OnUnitAnimation(data: table
): nil
table
): nil
Called when a unit animation is played.
OnUnitAnimationEnd(data: table
): nil
table
): nil
Called when a unit animation ends.
OnProjectile(data: table
): nil
table
): nil
Called when new projectile is created.
OnProjectileLoc(data: table
): nil
table
): nil
Called when new projectile loc is created.
OnLinearProjectileCreate(data: table
): nil
table
): nil
Called when new linear projectile is created.
OnLinearProjectileDestroy(data: table
): nil
table
): nil
Called when linear projectile is destroyed.
OnParticleCreate(data: table
): nil
table
): nil
Called when new particle is created.
OnParticleDestroy(data: table
): nil
table
): nil
Called when particle is updated.
OnParticleUpdateFallback(data: table
): nil
table
): nil
Called when particle is updated. Alternative version for some particles.
OnParticleUpdateEntity(data: table
): nil
table
): nil
Called when particle is updated on entity.
OnParticleDestroy(data: table
): nil
table
): nil
Called when particle is destroyed.
OnStartSound(data: table
): nil
table
): nil
Called when sound is started.
OnChatEvent(data: table
): nil
table
): nil
Called on chat event.
OnOverHeadEvent(data: {player_source:CPlayer|nil, player_target:CPlayer|nil, target_npc:CNPC, value:integer}
): nil
{player_source:CPlayer|nil, player_target:CPlayer|nil, target_npc:CNPC, value:integer}
): nil
Called on event above the hero's head.
OnUnitAddGesture(data: table
): nil
table
): nil
Called when a unit is added to a gesture.
OnPrepareUnitOrders(data: table
): boolean
table
): boolean
Called on every player order. Return false to prevent the order from being executed.
OnGCMessage(data: table
): boolean
table
): boolean
Called when a game coordinator protobuff message is received. Return false to prevent the message from being sent (doesnt work with recieved messages). For more look at GC table description.
Example
OnSendNetMessage(data: table
): boolean
table
): boolean
Called when a net message is sent. Return false to prevent the message from being sent. See example
Example
OnPostReceivedNetMessage(data: table
): boolean
table
): boolean
Called when a net message is received. Return false to prevent the message from being recieved
Example
Called on NPC dormancy state changed.
OnGameRulesStateChange(data: {}
): nil
{}
): nil
Called on gamestate change.
OnNpcDying(npc: CNPC
): nil
CNPC
): nil
Called on NPC dying.
Last updated