Modding Callbacks

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
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_POST_UPDATE
Triggers when the game updates.

The format of this callback function is:

MC_POST_RENDER
Triggers every frame.

The format of this callback function is:

MC_USE_ITEM
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_POST_PEFFECT_UPDATE
Triggers every frame, for every player.

The format of this callback function is:

MC_USE_CARD
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_FAMILIAR_UPDATE
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_ENTITY_TAKE_DAMAGE
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: