Modding Callbacks

From Binding of Isaac: Rebirth Wiki
Jump to: navigation, search

Callbacks are how modders hook in to Afterbirth+ and make different functions execute. Without callbacks, there's no way to execute user code.

To add a callback, call modname:AddCallback(ModCallbacks.ENUM, fn, params)

where ENUM corresponds to the callback you'd like to hook into, fn is your function name, and params are optional extra parameters for this callback. Any name can be used for your callback function.

MC_NPC_UPDATE[edit | edit source]

Triggers when an NPC is updated. Passing an EntityType as a parameter will cause the callback to trigger only when entities of that type are updated.

The format of this callback function is:

MC_NPC_UPDATE
EntityType entityType - If supplied, only triggers when the specified entity type is updated.
Description
This callback function is called after an NPC is updated.
Arguments Returns
EntityNPC entity
The entity that has been updated.
None.
Examples
None.


MC_POST_UPDATE[edit | edit source]

Triggers when the game updates.

The format of this callback function is:

MC_POST_UPDATE
No Parameter.
Description
This callback function is called after the game updates.
Arguments Returns
None. None.
Examples
None.


MC_POST_RENDER[edit | edit source]

Triggers every frame.

The format of this callback function is:

MC_POST_RENDER
No Parameter.
Description
This callback function is called every time the game is rendered to the user's screen
Arguments Returns
None. None.
Examples
None.


MC_USE_ITEM[edit | edit source]

Triggers when an active item is used. Passing an item ID as a parameter will cause the callback to trigger only when an item with that ID is used.

The format of this callback function is:

MC_USE_ITEM
number ItemId - If supplied, only triggers if the used item matches the supplied item ID.
Description
This callback function is called when an item is used. The return values do not prevent the item from being used, only from playing the animation.
Arguments Returns
number collectible
The ID of the collectible used.
RNG seed
Useful to allow the item's random events to be seeded.
boolean true
Plays the use item animation.
boolean false (default)
Does not play the use item animation.
Examples
None.


MC_POST_PEFFECT_UPDATE[edit | edit source]

Triggers every frame, for every player.

The format of this callback function is:

MC_POST_PEFFECT_UPDATE
No Parameter.
Description
This callback function is called every frame, after the player evaluates the effects of items that are constantly evaluated.
Arguments Returns
EntityPlayer player
The player entity that the callback has been called for.
None.
Examples
None.


MC_USE_CARD[edit | edit source]

Triggers when a card is used. Passing a card ID as a parameter will cause the callback to trigger only when the used card has that card ID.

The format of this callback function is:

MC_USE_CARD
Card card - If supplied, only triggers when the specified card is used.
Description
This callback function is called whenever a card is used.
Arguments Returns
Card card
The card that has been used.
None.
Examples
None.


MC_FAMILIAR_UPDATE[edit | edit source]

Triggers every frame for each familiar. Passing a familiar variant will cause the callback to trigger only when that familiar updates.

The format of this callback function is:

MC_FAMILIAR_UPDATE
FamiliarVariant variant - If supplied, only triggers when the specified familiar variant updates.
Description
This callback function is called whenever a familiar is updated.
Arguments Returns
EntityFamiliar familiar
The familiar that has been updated.
None.
Examples
None.


MC_ENTITY_TAKE_DAMAGE[edit | edit source]

Triggers when an entity takes damage. Passing an entity as a parameter will cause the callback to trigger only when that entity is damaged. If an attacked entity is immune to damage, this callback will not trigger.

The format of this callback function is:

MC_ENTITY_TAKE_DAMAGE
Entity entity - If supplied, only triggers when the specified entity is damaged.
Description
This callback function is called before damage is applied. It can nullify the damage or inspect the state of entities before damage is applied.
Arguments Returns
Entity target
The entity of the target being damaged. Isaac, NPC, etc.
number damage
The amount of damage. Usually 1 if applied to Isaac, can vary to others.
Bitmask flags
A collection of DamageFlags representing properties of this damage or its source.
Entity source
The entity of the source of the damage, if any.
boolean true (default)
Deals the damage.
boolean false
Cancels the damage.
Examples
None.