isaacscript-common 1.2.25 → 1.2.29
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/features/sirenHelpers.lua +11 -11
- package/dist/functions/flying.lua +6 -0
- package/dist/functions/rooms.d.ts +4 -1
- package/dist/functions/rooms.lua +4 -2
- package/dist/functions/sound.d.ts +1 -0
- package/dist/functions/sound.lua +11 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.lua +16 -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
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
3
|
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
4
4
|
local ____exports = {}
|
|
5
|
-
local postNPCInitSirenHelper, checkReturnFamiliarToPlayer, blacklistEntryExists, v
|
|
5
|
+
local postNPCInitSirenHelper, checkReturnFamiliarToPlayer, blacklistEntryExists, getSirenHelper, v
|
|
6
6
|
local ____errors = require("errors")
|
|
7
7
|
local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
|
|
8
8
|
local ____entity = require("functions.entity")
|
|
@@ -38,6 +38,16 @@ function blacklistEntryExists(self, incomingFamiliarVariant, incomingFamiliarSub
|
|
|
38
38
|
end
|
|
39
39
|
return false
|
|
40
40
|
end
|
|
41
|
+
function getSirenHelper(self, familiar)
|
|
42
|
+
local familiarHash = GetPtrHash(familiar)
|
|
43
|
+
local sirenHelpers = getEntities(nil, EntityType.ENTITY_SIREN_HELPER)
|
|
44
|
+
for ____, sirenHelper in ipairs(sirenHelpers) do
|
|
45
|
+
if sirenHelper.Target ~= nil and GetPtrHash(sirenHelper.Target) == familiarHash then
|
|
46
|
+
return sirenHelper
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
return nil
|
|
50
|
+
end
|
|
41
51
|
local FEATURE_NAME = "siren helpers"
|
|
42
52
|
local initialized = false
|
|
43
53
|
v = {run = {familiarBlacklist = {}}}
|
|
@@ -56,16 +66,6 @@ function ____exports.setFamiliarNoSirenSteal(self, familiarVariant, familiarSubT
|
|
|
56
66
|
end
|
|
57
67
|
__TS__ArrayPush(v.run.familiarBlacklist, {familiarVariant, familiarSubType})
|
|
58
68
|
end
|
|
59
|
-
local function getSirenHelper(self, familiar)
|
|
60
|
-
local familiarHash = GetPtrHash(familiar)
|
|
61
|
-
local sirenHelpers = getEntities(nil, EntityType.ENTITY_SIREN_HELPER)
|
|
62
|
-
for ____, sirenHelper in ipairs(sirenHelpers) do
|
|
63
|
-
if sirenHelper.Target ~= nil and GetPtrHash(sirenHelper.Target) == familiarHash then
|
|
64
|
-
return sirenHelper
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
return nil
|
|
68
|
-
end
|
|
69
69
|
function ____exports.hasSirenStolenFamiliar(self, familiar)
|
|
70
70
|
return getSirenHelper(nil, familiar) ~= nil
|
|
71
71
|
end
|
|
@@ -18,6 +18,7 @@ local FLYING_CHARACTERS = __TS__New(Set, {
|
|
|
18
18
|
PlayerType.PLAYER_THESOUL_B
|
|
19
19
|
})
|
|
20
20
|
local FLYING_TRINKETS = __TS__New(Set, {TrinketType.TRINKET_BAT_WING, TrinketType.TRINKET_AZAZELS_STUMP})
|
|
21
|
+
local FLYING_NULL_ITEMS = {NullItemID.ID_REVERSE_SUN, NullItemID.ID_SPIRIT_SHACKLES_SOUL}
|
|
21
22
|
function ____exports.getFlyingCollectibles(self, pruneConditionalItems)
|
|
22
23
|
local collectiblesWithFlyingCacheFlag = getCollectiblesForCacheFlag(nil, CacheFlag.CACHE_FLYING)
|
|
23
24
|
local collectiblesWithAllCacheFlag = getCollectiblesForCacheFlag(nil, CacheFlag.CACHE_ALL)
|
|
@@ -47,6 +48,11 @@ function ____exports.hasFlyingTemporaryEffect(self, player)
|
|
|
47
48
|
return true
|
|
48
49
|
end
|
|
49
50
|
end
|
|
51
|
+
for ____, nullItemID in ipairs(FLYING_NULL_ITEMS) do
|
|
52
|
+
if effects:HasNullEffect(nullItemID) then
|
|
53
|
+
return true
|
|
54
|
+
end
|
|
55
|
+
end
|
|
50
56
|
return false
|
|
51
57
|
end
|
|
52
58
|
function ____exports.isFlyingCharacter(self, player)
|
|
@@ -43,8 +43,11 @@ export declare function getRoomDescriptor(roomGridIndex?: int): RoomDescriptor;
|
|
|
43
43
|
* specified room type.
|
|
44
44
|
*
|
|
45
45
|
* This function only searches through rooms in the current dimension.
|
|
46
|
+
*
|
|
47
|
+
* This function is variadic, meaning that you can specify N arguments to get the combined grid
|
|
48
|
+
* indexes for N room types.
|
|
46
49
|
*/
|
|
47
|
-
export declare function getRoomGridIndexesForType(
|
|
50
|
+
export declare function getRoomGridIndexesForType(...roomTypes: RoomType[]): int[];
|
|
48
51
|
/**
|
|
49
52
|
* Helper function to get the item pool type for the current room. For example, this returns
|
|
50
53
|
* `ItemPoolType.ItemPoolType.POOL_ANGEL` if you are in an Angel Room.
|
package/dist/functions/rooms.lua
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
3
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
4
|
+
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
|
|
4
5
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
5
6
|
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
6
7
|
local Set = ____lualib.Set
|
|
@@ -132,11 +133,12 @@ function ____exports.getRoomDataType(self, roomGridIndex)
|
|
|
132
133
|
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
133
134
|
return roomData == nil and -1 or roomData.Type
|
|
134
135
|
end
|
|
135
|
-
function ____exports.getRoomGridIndexesForType(self,
|
|
136
|
+
function ____exports.getRoomGridIndexesForType(self, ...)
|
|
137
|
+
local roomTypes = {...}
|
|
136
138
|
local rooms = ____exports.getRooms(nil)
|
|
137
139
|
local matchingRooms = __TS__ArrayFilter(
|
|
138
140
|
rooms,
|
|
139
|
-
function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomDescriptor.Data.Type
|
|
141
|
+
function(____, roomDescriptor) return roomDescriptor.Data ~= nil and __TS__ArrayIncludes(roomTypes, roomDescriptor.Data.Type) end
|
|
140
142
|
)
|
|
141
143
|
return __TS__ArrayMap(
|
|
142
144
|
matchingRooms,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stopAllSoundEffects(): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local ____util = require("functions.util")
|
|
4
|
+
local getEnumValues = ____util.getEnumValues
|
|
5
|
+
function ____exports.stopAllSoundEffects(self)
|
|
6
|
+
local sfxManager = SFXManager()
|
|
7
|
+
for ____, soundEffect in ipairs(getEnumValues(nil, SoundEffect)) do
|
|
8
|
+
sfxManager:Stop(soundEffect)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
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";
|
|
@@ -45,6 +45,7 @@ export * from "./functions/revive";
|
|
|
45
45
|
export * from "./functions/rooms";
|
|
46
46
|
export * from "./functions/seeds";
|
|
47
47
|
export * from "./functions/set";
|
|
48
|
+
export * from "./functions/sound";
|
|
48
49
|
export * from "./functions/spawnCollectible";
|
|
49
50
|
export * from "./functions/sprite";
|
|
50
51
|
export * from "./functions/stage";
|
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")
|
|
@@ -366,6 +370,14 @@ do
|
|
|
366
370
|
end
|
|
367
371
|
end
|
|
368
372
|
end
|
|
373
|
+
do
|
|
374
|
+
local ____export = require("functions.sound")
|
|
375
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
376
|
+
if ____exportKey ~= "default" then
|
|
377
|
+
____exports[____exportKey] = ____exportValue
|
|
378
|
+
end
|
|
379
|
+
end
|
|
380
|
+
end
|
|
369
381
|
do
|
|
370
382
|
local ____export = require("functions.spawnCollectible")
|
|
371
383
|
for ____exportKey, ____exportValue in pairs(____export) do
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.29",
|
|
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",
|