🔄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.
data
{source:CEntity|nil, target:CEntity|nil, ability:CAbility|nil, damage:number}
The data about the event.
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.
data
{source:CEntity|nil, target:CEntity|nil, ability:CAbility|nil}
The data about the event.
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.
data
{name:string, event:Event}
The data about the event.
Called when a game event is fired.
OnUnitAnimation(data: table
): nil
table
): nil
data
table
The data about the event.
.sequenceVariant
number
The sequence variant.
.playbackRate
number
The playback rate.
.castpoint
number
The castpoint.
.type
integer
The type.
.activity
integer
The activity.
.sequence
integer
The sequence.
.sequenceName
string
The sequence name.
.lag_compensation_time
number
The lag compensation time.
Called when a unit animation is played.
OnUnitAnimationEnd(data: table
): nil
table
): nil
data
table
The data about the event.
.snap
boolean
The snap.
Called when a unit animation ends.
OnProjectile(data: table
): nil
table
): nil
data
table
The data about the event.
.moveSpeed
integer
The move speed.
.sourceAttachment
integer
The source attachment.
.particleSystemHandle
integer
The particle system handle.
.dodgeable
boolean
The dodgeable.
.isAttack
boolean
The is attack.
.expireTime
number
The expire time.
.maxImpactTime
number
The max impact time.
.launch_tick
integer
The tick the pojectile was launched.
.colorGemColor
integer
The color gem color.
.fullName
string
The full name of projectile.
.name
string
The short name of projectile.
.handle
integer
The handle of projectile.
.original_move_speed
integer
The original move speed.
Called when new projectile is created.
OnProjectileLoc(data: table
): nil
table
): nil
data
table
The data about the event.
.moveSpeed
integer
The move speed.
.original_move_speed
integer
The original move speed.
.particleSystemHandle
integer
The particle system handle.
.dodgeable
boolean
The dodgeable.
.isAttack
boolean
The is attack.
.expireTime
number
The expire time.
.colorGemColor
integer
The color gem color.
.launchTick
integer
The launch tick.
.handle
integer
The handle of projectile.
.fullName
string
The full name of projectile.
.name
string
The short name of projectile.
Called when new projectile loc is created.
OnLinearProjectileCreate(data: table
): nil
table
): nil
data
table
The data about the event.
.particleIndex
integer
The particle index.
.handle
integer
The handle of projectile.
.maxSpeed
number
The max speed.
.fowRadius
number
The fow radius.
.distance
number
The distance.
.colorGemColor
integer
The color gem color.
.fullName
string
The full name of projectile.
.name
string
The short name of projectile.
Called when new linear projectile is created.
OnLinearProjectileDestroy(data: table
): nil
table
): nil
data
table
The data about the event.
.handle
integer
The handle of projectile.
Called when linear projectile is destroyed.
OnParticleCreate(data: table
): nil
table
): nil
data
table
The data about the event.
.index
integer
The index of particle.
.entity_id
integer
The entity id.
.entity_for_modifiers_id
integer
The entity for modifiers id.
.fullName
string
The full name of particle.
.name
string
The short name of particle.
.hash
integer
The hash of particle.
.particleNameIndex
integer
The particle name index.
Called when new particle is created.
OnParticleDestroy(data: table
): nil
table
): nil
data
table
The data about the event.
.index
integer
The index of particle.
.controlPoint
integer
The control point.
Called when particle is updated.
OnParticleUpdateFallback(data: table
): nil
table
): nil
data
table
The data about the event.
.index
integer
The index of particle.
.controlPoint
integer
The control point.
Called when particle is updated. Alternative version for some particles.
OnParticleUpdateEntity(data: table
): nil
table
): nil
data
table
The data about the event.
.index
integer
The index of particle.
.controlPoint
integer
The control point.
.entIdx
integer
The entity id.
.attachmentName
string
The attachment name.
.includeWearables
boolean
Include wearables.
Called when particle is updated on entity.
OnParticleDestroy(data: table
): nil
table
): nil
data
table
The data about the event.
.index
integer
The index of destroyed particle.
.destroyImmediately
boolean
Destroy immediately.
Called when particle is destroyed.
OnStartSound(data: table
): nil
table
): nil
Called when sound is started.
OnChatEvent(data: table
): nil
table
): nil
data
table
The data about the event.
.type
integer
The type of chat event.
.value
integer
The value of chat event.
.value2
integer
The value2 of chat event.
.value3
integer
The value3 of chat event.
.playerid_1
integer
The playerid_1 of chat event.
.playerid_2
integer
The playerid_2 of chat event.
.playerid_3
integer
The playerid_3 of chat event.
.playerid_4
integer
The playerid_4 of chat event.
.playerid_5
integer
The playerid_5 of chat event.
.playerid_6
integer
The playerid_6 of chat event.
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
data
{player_source:CPlayer|nil, player_target:CPlayer|nil, target_npc:CNPC, value:integer}
The table with the event info.
Called on event above the hero's head.
OnUnitAddGesture(data: table
): nil
table
): nil
data
table
The data about the event.
.sequenceVariant
integer
The sequence variant.
.playbackRate
number
The playback rate.
.fadeIn
number
The fade in.
.fadeOut
number
The fade out.
.slot
integer
The slot.
.activity
integer
The activity.
.sequenceName
string
The sequence name.
Called when a unit is added to a gesture.
OnPrepareUnitOrders(data: table
): boolean
table
): boolean
data
table
The data about the event.
.queue
boolean
If the order is queued.
.showEffects
boolean
The show effects of the order.
Called on every player order. Return false to prevent the order from being executed.
OnGCMessage(data: table
): boolean
table
): boolean
data
table
.msg_type
number
The message type.
.size
number
The size of the message.
.binary_buffer_send [?]
userdata
The binary buffer of the send message. (default: nil)
.binary_buffer_recv [?]
userdata
The binary buffer of the recieved message. (default: nil)
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
data
table
The data about the event.
.message_id
number
The message id.
.message_name
string
The message name.
.buffer
lightuserdata
The encoded buffer of the message.
.size
number
The size of the message.
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
data
table
The data about the event.
.message_id
number
The message id.
.msg_object
lightuserdata
The encoded buffer of the message.
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
data
{}
The table with new game state info.
Called on gamestate change.
OnNpcDying(npc: CNPC
): nil
CNPC
): nil
Called on NPC dying.
Last updated