isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
33 lines • 1.73 kB
TypeScript
import type { ISCFeature } from "../enums/ISCFeature";
import type { ModUpgradedWithFeatures } from "../types/private/ModUpgradedWithFeatures";
type ISCFeatureTuple<T extends readonly ISCFeature[]> = ISCFeature extends T["length"] ? 'The list of features must be a tuple. Use the "as const" assertion when declaring the array.' : T;
/**
* Use this function to enable the custom callbacks and other optional features provided by
* `isaacscript-common`.
*
* For example:
*
* ```ts
* const modVanilla = RegisterMod("My Mod", 1);
* const mod = upgradeMod(modVanilla);
*
* // Subscribe to vanilla callbacks.
* mod.AddCallback(ModCallback.POST_UPDATE, postUpdate);
*
* // Subscribe to custom callbacks.
* mod.AddCallbackCustom(ModCallbackCustom.POST_ITEM_PICKUP, postItemPickup);
* ```
*
* @param modVanilla The mod object returned by the `RegisterMod` function.
* @param features Optional. An array containing the optional standard library features that you
* want to enable, if any. Default is an empty array.
* @param debug Optional. Whether to log additional output when a callback is fired. Default is
* false.
* @param timeThreshold Optional. If provided, will only log callbacks that take longer than the
* specified number of seconds (if the "--luadebug" launch flag is turned on)
* or milliseconds (if the "--luadebug" launch flag is turned off).
* @returns The upgraded mod object.
*/
export declare function upgradeMod<T extends readonly ISCFeature[] = never[]>(modVanilla: Mod, features?: ISCFeatureTuple<T>, debug?: boolean, timeThreshold?: float): ModUpgradedWithFeatures<T>;
export {};
//# sourceMappingURL=upgradeMod.d.ts.map