Skip to content

Run In N Frames

Defined in: packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:39

  • Feature

vConditionalFunc(): boolean

Defined in: packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:79

boolean

Feature.vConditionalFunc

restartNextRenderFrame(character?): void

Defined in: packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:109

Helper function to restart on the next render frame. Useful because it is impossible to restart the game inside of the POST_NEW_ROOM, POST_NEW_LEVEL, or POST_GAME_STARTED callbacks when a run is first starting.

In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES.

PlayerType

Optional. If specified, will restart the game as the specified character.

void

runInNGameFrames(func, numGameFrames, cancelIfRoomChanges?): void

Defined in: packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:134

Supply a function to run N game frames from now in the POST_UPDATE callback.

For a usage example, see the documentation for the runNextGameFrame, which is used in a similar way.

Note that this function will not handle saving and quitting. If a player saving and quitting before the deferred function fires would cause a bug in your mod, then you should handle deferred functions manually using serializable data.

In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES.

() => void

The function to run.

int

The amount of game frames to wait before running the function.

boolean = false

Optional. Whether to cancel running the function if a new room is loaded in the interim. Default is false.

void

runInNRenderFrames(func, numRenderFrames, cancelIfRoomChanges?): void

Defined in: packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:171

Supply a function to run N render frames from now in the POST_RENDER callback.

For a usage example, see the documentation for the runNextGameFrame, which is used in a similar way.

Note that this function will not handle saving and quitting. If a player saving and quitting before the deferred function fires would cause a bug in your mod, then you should handle deferred functions manually using serializable data.

In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES.

() => void

The function to run.

int

The amount of render frames to wait before running the function.

boolean = false

Optional. Whether to cancel running the function if a new room is loaded in the interim. Default is false.

void

runNextGameFrame(func, cancelIfRoomChanges?): void

Defined in: packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:225

Supply a function to run on the next POST_UPDATE callback.

For example:

const NUM_EXPLODER_EXPLOSIONS = 5;
function useItemExploder(player: EntityPlayer) {
playSound("exploderBegin");
explode(player, NUM_EXPLODER_EXPLOSIONS);
}
function explode(player: EntityPlayer, numFramesLeft: int) {
Isaac.Explode(player, undefined, 1);
numFramesLeft -= 1;
if (numFramesLeft === 0) {
runNextFrame(() => {
explode(player, numFramesLeft);
});
}
}

Note that this function will not handle saving and quitting. If a player saving and quitting before the deferred function fires would cause a bug in your mod, then you should handle deferred functions manually using serializable data.

In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES.

() => void

The function to run.

boolean = false

Optional. Whether to cancel running the function if a new room is loaded in the interim. Default is false.

void

runNextRenderFrame(func, cancelIfRoomChanges?): void

Defined in: packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:245

Supply a function to run on the next POST_RENDER callback.

For a usage example, see the documentation for the runNextGameFrame, which is used in a similar way.

Note that this function will not handle saving and quitting.

In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES.

() => void

The function to run.

boolean = false

Optional. Whether to cancel running the function if a new room is loaded in the interim. Default is false.

void

setIntervalGameFrames(func, numGameFrames, runImmediately, cancelIfRoomChanges?): void

Defined in: packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:274

Supply a function to be repeatedly run on an interval of N game frames in the POST_UPDATE callback. The function will continue to be fired until false is returned from the function.

This is similar to the setInterval vanilla JavaScript function, except there is no corresponding clearInterval function. (Instead, the return value from the supplied function is used to stop the interval.)

Note that this function will not handle saving and quitting. You must manually restart any intervals if the player saves and quits in the middle of a run.

In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES.

() => boolean

The function to repeatedly run on an interval.

int

The amount of game frames to wait between each run.

boolean

Whether to execute the function right now before waiting for the interval.

boolean = false

Optional. Whether to cancel running the function if a new room is loaded in the interim. Default is false.

void

setIntervalRenderFrames(func, numRenderFrames, runImmediately, cancelIfRoomChanges?): void

Defined in: packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:322

Supply a function to be repeatedly run on an interval of N render frames in the POST_RENDER callback. The function will continue to be fired until false is returned from the function.

This is similar to the setInterval vanilla JavaScript function, except there is no corresponding clearInterval function. (Instead, the return value from the supplied function is used to stop the interval.)

Note that this function will not handle saving and quitting. You must manually restart any intervals if the player saves and quits in the middle of a run.

In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES.

() => boolean

The function to repeatedly run on an interval.

int

The amount of game frames to wait between each run.

boolean

Whether to execute the function right now before waiting for the interval.

boolean = false

Optional. Whether to cancel running the function if a new room is loaded in the interim. Default is false.

void