Skip to content

ModUpgraded

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:33

isaacscript-common has many custom callbacks that you can use in your mods. Instead of hijacking the vanilla Mod object, we provide a ModUpgraded object for you to use, which extends the base class and adds a new method of AddCallbackCustom.

To upgrade your mod, use the upgradeMod helper function.

By specifying one or more optional features when upgrading your mod, you will get a version of ModUpgraded that has extra methods corresponding to the features that were specified. (This corresponds to the internal-type ModUpgradedWithFeatures type, which extends ModUpgraded.)

  • Mod

new ModUpgraded(mod, debug, timeThreshold?): ModUpgraded

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:57

Mod

boolean

float

ModUpgraded

readonly Name: string

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:51

The RegisterMod function stores the name of the mod on the mod object for some reason. (It is never used or referenced.)

Mod.Name

AddCallback<T>(modCallback, …args): void

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:215

Registers a function to be executed when an in-game event happens. For example, the ModCallback.POST_UPDATE event corresponds to an in-game logic frame being finished.

The different types of callbacks are represented in the ModCallback enum.

Some callbacks take an optional third argument to specify that you only want it the function to fire on a specific thing. For example:

mod.AddCallback(
ModCallback.POST_EFFECT_UPDATE,
postEffectUpdatePoof1,
EffectVariant.POOF_1,
)

T extends string | keyof AddCallbackParameters

T

T extends keyof AddCallbackParameters ? AddCallbackParameters[T] : unknown[]

void

Mod.AddCallback

AddPriorityCallback<T>(modCallback, priority, …args): void

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:224

The same as the Mod.AddCallback method, but allows setting a custom priority. By default, callbacks are added with a priority of 0, so this allows you to add early or late callbacks as necessary. See the CallbackPriority enum.

T extends string | keyof AddCallbackParameters

T

int | CallbackPriority

T extends keyof AddCallbackParameters ? AddCallbackParameters[T] : unknown[]

void

Mod.AddPriorityCallback

HasData(): boolean

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:285

Returns whether a corresponding “save#.dat” file exists for the current mod.

boolean

Mod.HasData

LoadData(): string

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:289

Returns a string containing all of the data inside of the corresponding “save#.dat” file for this mod.

string

Mod.LoadData

RemoveCallback<T>(modCallback, callback): void

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:293

Unregisters a function that was previously registered with the AddCallback method.

This method does not care about the tertiary argument. In other words, regardless of the conditions of how you registered the callback, it will be removed.

T extends ModCallback

T

AddCallbackParameters[T][0]

void

Mod.RemoveCallback

RemoveData(): void

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:300

Deletes the corresponding “save#.dat” file for this mod, if it exists.

void

Mod.RemoveData

SaveData(data): void

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:304

Creates or updates the corresponding “save#.dat” file for this mod with the provided string.

string

void

Mod.SaveData

AddCallbackCustom<T>(modCallbackCustom, …args): void

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:319

Registers a function to be executed when an in-game event happens.

This method is specifically for events that are provided by the IsaacScript standard library. For example, the ModCallbackCustom.POST_BOMB_EXPLODE event corresponds to when a bomb explodes.

T extends ModCallbackCustom

T

AddCallbackParametersCustom[T]

void

AddPriorityCallbackCustom<T>(modCallbackCustom, priority, …args): void

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:335

The same as the ModUpgraded.AddCallbackCustom method, but allows setting a custom priority. By default, callbacks are added with a priority of 0, so this allows you to add early or late callbacks as necessary. See the CallbackPriority enum.

T extends ModCallbackCustom

T

int | CallbackPriority

AddCallbackParametersCustom[T]

void

RemoveCallbackCustom<T>(modCallbackCustom, callback): void

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:357

Unregisters a function that was previously registered with the AddCallbackCustom method.

This method is specifically for events that are provided by the IsaacScript standard library. For example, the ModCallbackCustom.POST_BOMB_EXPLODE event corresponds to when a bomb explodes.

This method does not care about the tertiary argument. In other words, regardless of the conditions of how you registered the callback, it will be removed.

T extends ModCallbackCustom

T

AddCallbackParametersCustom[T][0]

void

logUsedFeatures(): void

Defined in: packages/isaacscript-common/src/classes/ModUpgraded.ts:371

Logs every custom callback or extra feature that is currently enabled. Useful for debugging or profiling.

void