isaacscript-common 1.2.26 → 1.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/runInNFrames.d.ts +29 -9
- package/dist/features/runInNFrames.lua +41 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.lua +8 -4
- package/package.json +2 -2
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/**
|
|
3
|
+
* Supply a function to run N game frames from now in the PostUpdate callback.
|
|
4
|
+
*
|
|
5
|
+
* For a usage example, see the documentation for the `runNextGameFrame`, which is used in a similar
|
|
6
|
+
* way.
|
|
7
|
+
*
|
|
8
|
+
* Note that this function will not handle saving and quitting. If a player saving and quitting
|
|
9
|
+
* before the deferred function fires would cause a bug in your mod, then you should handle deferred
|
|
10
|
+
* functions manually using serializable data.
|
|
11
|
+
*/
|
|
12
|
+
export declare function runInNGameFrames(func: () => void, frames: int): void;
|
|
13
|
+
/**
|
|
14
|
+
* Supply a function to run N render frames from now in the PostRender callback.
|
|
15
|
+
*
|
|
16
|
+
* For a usage example, see the documentation for the `runNextGameFrame`, which is used in a similar
|
|
17
|
+
* way.
|
|
18
|
+
*
|
|
19
|
+
* Note that this function will not handle saving and quitting. If a player saving and quitting
|
|
20
|
+
* before the deferred function fires would cause a bug in your mod, then you should handle deferred
|
|
21
|
+
* functions manually using serializable data.
|
|
22
|
+
*/
|
|
23
|
+
export declare function runInNRenderFrames(func: () => void, frames: int): void;
|
|
2
24
|
/**
|
|
3
25
|
* Supply a function to run on the next PostUpdate callback.
|
|
4
26
|
*
|
|
@@ -22,19 +44,17 @@
|
|
|
22
44
|
* }
|
|
23
45
|
* ```
|
|
24
46
|
*
|
|
25
|
-
* Note that this function will not handle saving and quitting
|
|
26
|
-
* before the
|
|
47
|
+
* Note that this function will not handle saving and quitting. If a player saving and quitting
|
|
48
|
+
* before the deferred function fires would cause a bug in your mod, then you should handle deferred
|
|
27
49
|
* functions manually using serializable data.
|
|
28
50
|
*/
|
|
29
|
-
export declare function
|
|
51
|
+
export declare function runNextGameFrame(func: () => void): void;
|
|
30
52
|
/**
|
|
31
|
-
* Supply a function to run
|
|
53
|
+
* Supply a function to run on the next PostRender callback.
|
|
32
54
|
*
|
|
33
|
-
* For a usage example, see the documentation for the `
|
|
55
|
+
* For a usage example, see the documentation for the `runNextGameFrame`, which is used in a similar
|
|
34
56
|
* way.
|
|
35
57
|
*
|
|
36
|
-
* Note that this function will not handle saving and quitting
|
|
37
|
-
* before the next PostUpdate frame would cause a bug in your mod, then you should handle deferred
|
|
38
|
-
* functions manually using serializable data.
|
|
58
|
+
* Note that this function will not handle saving and quitting.
|
|
39
59
|
*/
|
|
40
|
-
export declare function
|
|
60
|
+
export declare function runNextRenderFrame(func: () => void): void;
|
|
@@ -3,7 +3,7 @@ local ____lualib = require("lualib_bundle")
|
|
|
3
3
|
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
4
4
|
local __TS__ArraySplice = ____lualib.__TS__ArraySplice
|
|
5
5
|
local ____exports = {}
|
|
6
|
-
local postUpdate,
|
|
6
|
+
local postUpdate, postRender, checkExecuteQueuedFunctions, v
|
|
7
7
|
local ____errors = require("errors")
|
|
8
8
|
local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
|
|
9
9
|
local ____exports = require("features.saveDataManager.exports")
|
|
@@ -11,14 +11,21 @@ local saveDataManager = ____exports.saveDataManager
|
|
|
11
11
|
function postUpdate(self)
|
|
12
12
|
local game = Game()
|
|
13
13
|
local gameFrameCount = game:GetFrameCount()
|
|
14
|
+
checkExecuteQueuedFunctions(nil, gameFrameCount, v.run.queuedGameFunctionTuples)
|
|
15
|
+
end
|
|
16
|
+
function postRender(self)
|
|
17
|
+
local isaacFrameCount = Isaac.GetFrameCount()
|
|
18
|
+
checkExecuteQueuedFunctions(nil, isaacFrameCount, v.run.queuedRenderFunctionTuples)
|
|
19
|
+
end
|
|
20
|
+
function checkExecuteQueuedFunctions(self, frameCount, functionTuples)
|
|
14
21
|
local functionsToFire = {}
|
|
15
22
|
local indexesToRemove = {}
|
|
16
23
|
do
|
|
17
24
|
local i = 0
|
|
18
|
-
while i < #
|
|
19
|
-
local functionTuple =
|
|
25
|
+
while i < #functionTuples do
|
|
26
|
+
local functionTuple = functionTuples[i + 1]
|
|
20
27
|
local frame, func = table.unpack(functionTuple)
|
|
21
|
-
if
|
|
28
|
+
if frameCount >= frame then
|
|
22
29
|
__TS__ArrayPush(functionsToFire, func)
|
|
23
30
|
__TS__ArrayPush(indexesToRemove, i)
|
|
24
31
|
end
|
|
@@ -26,13 +33,22 @@ function postUpdate(self)
|
|
|
26
33
|
end
|
|
27
34
|
end
|
|
28
35
|
for ____, indexToRemove in ipairs(indexesToRemove) do
|
|
29
|
-
__TS__ArraySplice(
|
|
36
|
+
__TS__ArraySplice(functionTuples, indexToRemove, 1)
|
|
30
37
|
end
|
|
31
38
|
for ____, func in ipairs(functionsToFire) do
|
|
32
39
|
func(nil)
|
|
33
40
|
end
|
|
34
41
|
end
|
|
35
|
-
|
|
42
|
+
local FEATURE_NAME = "run in N frames"
|
|
43
|
+
local initialized = false
|
|
44
|
+
v = {dontSave = true, run = {queuedGameFunctionTuples = {}, queuedRenderFunctionTuples = {}}}
|
|
45
|
+
function ____exports.runInNFramesInit(self, mod)
|
|
46
|
+
initialized = true
|
|
47
|
+
saveDataManager(nil, "runInNFrames", v)
|
|
48
|
+
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, postUpdate)
|
|
49
|
+
mod:AddCallback(ModCallbacks.MC_POST_RENDER, postRender)
|
|
50
|
+
end
|
|
51
|
+
function ____exports.runInNGameFrames(self, func, frames)
|
|
36
52
|
if not initialized then
|
|
37
53
|
local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
|
|
38
54
|
error(msg)
|
|
@@ -41,21 +57,30 @@ function ____exports.runInNFrames(self, func, frames)
|
|
|
41
57
|
local gameFrameCount = game:GetFrameCount()
|
|
42
58
|
local functionFireFrame = gameFrameCount + frames
|
|
43
59
|
local tuple = {functionFireFrame, func}
|
|
44
|
-
__TS__ArrayPush(v.run.
|
|
60
|
+
__TS__ArrayPush(v.run.queuedGameFunctionTuples, tuple)
|
|
45
61
|
end
|
|
46
|
-
|
|
47
|
-
initialized
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
function ____exports.runInNRenderFrames(self, func, frames)
|
|
63
|
+
if not initialized then
|
|
64
|
+
local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
|
|
65
|
+
error(msg)
|
|
66
|
+
end
|
|
67
|
+
local isaacFrameCount = Isaac.GetFrameCount()
|
|
68
|
+
local functionFireFrame = isaacFrameCount + frames
|
|
69
|
+
local tuple = {functionFireFrame, func}
|
|
70
|
+
__TS__ArrayPush(v.run.queuedRenderFunctionTuples, tuple)
|
|
71
|
+
end
|
|
72
|
+
function ____exports.runNextGameFrame(self, func)
|
|
73
|
+
if not initialized then
|
|
74
|
+
local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
|
|
75
|
+
error(msg)
|
|
76
|
+
end
|
|
77
|
+
____exports.runInNGameFrames(nil, func, 1)
|
|
53
78
|
end
|
|
54
|
-
function ____exports.
|
|
79
|
+
function ____exports.runNextRenderFrame(self, func)
|
|
55
80
|
if not initialized then
|
|
56
81
|
local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
|
|
57
82
|
error(msg)
|
|
58
83
|
end
|
|
59
|
-
____exports.
|
|
84
|
+
____exports.runInNRenderFrames(nil, func, 1)
|
|
60
85
|
end
|
|
61
86
|
return ____exports
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { disableAllInputs, disableAllInputsExceptFor, disableMovementInputs, dis
|
|
|
5
5
|
export { forgottenSwitch } from "./features/forgottenSwitch";
|
|
6
6
|
export { getCollectibleItemPoolType } from "./features/getCollectibleItemPoolType";
|
|
7
7
|
export { preventCollectibleRotate } from "./features/preventCollectibleRotate";
|
|
8
|
-
export {
|
|
8
|
+
export { runInNGameFrames, runInNRenderFrames, runNextGameFrame, runNextRenderFrame, } from "./features/runInNFrames";
|
|
9
9
|
export * from "./features/saveDataManager/exports";
|
|
10
10
|
export { hasSirenStolenFamiliar, setFamiliarNoSirenSteal, } from "./features/sirenHelpers";
|
|
11
11
|
export * from "./functions/array";
|
package/dist/index.lua
CHANGED
|
@@ -56,10 +56,14 @@ do
|
|
|
56
56
|
end
|
|
57
57
|
do
|
|
58
58
|
local ____runInNFrames = require("features.runInNFrames")
|
|
59
|
-
local
|
|
60
|
-
local
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
local runInNGameFrames = ____runInNFrames.runInNGameFrames
|
|
60
|
+
local runInNRenderFrames = ____runInNFrames.runInNRenderFrames
|
|
61
|
+
local runNextGameFrame = ____runInNFrames.runNextGameFrame
|
|
62
|
+
local runNextRenderFrame = ____runInNFrames.runNextRenderFrame
|
|
63
|
+
____exports.runInNGameFrames = runInNGameFrames
|
|
64
|
+
____exports.runInNRenderFrames = runInNRenderFrames
|
|
65
|
+
____exports.runNextGameFrame = runNextGameFrame
|
|
66
|
+
____exports.runNextRenderFrame = runNextRenderFrame
|
|
63
67
|
end
|
|
64
68
|
do
|
|
65
69
|
local ____export = require("features.saveDataManager.exports")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.27",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@zamiell/typescript-to-lua": "^1.4.0",
|
|
29
|
-
"isaac-typescript-definitions": "^1.0.
|
|
29
|
+
"isaac-typescript-definitions": "^1.0.339",
|
|
30
30
|
"isaacscript-lint": "^1.0.79",
|
|
31
31
|
"isaacscript-tsconfig": "^1.1.8",
|
|
32
32
|
"typedoc": "^0.22.11",
|