isaacscript-common 1.2.26 → 1.2.30

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.
@@ -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, so if a player saving and quitting
26
- * before the next PostUpdate frame would cause a bug in your mod, then you should handle deferred
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 runNextFrame(func: () => void): void;
51
+ export declare function runNextGameFrame(func: () => void): void;
30
52
  /**
31
- * Supply a function to run N frames from now in the PostUpdate callback.
53
+ * Supply a function to run on the next PostRender callback.
32
54
  *
33
- * For a usage example, see the documentation for the `runNextFrame`, which is used in a similar
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, so if a player 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 runInNFrames(func: () => void, frames: int): void;
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, FEATURE_NAME, initialized, v
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 < #v.run.queuedFunctionTuples do
19
- local functionTuple = v.run.queuedFunctionTuples[i + 1]
25
+ while i < #functionTuples do
26
+ local functionTuple = functionTuples[i + 1]
20
27
  local frame, func = table.unpack(functionTuple)
21
- if gameFrameCount >= frame then
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(v.run.queuedFunctionTuples, indexToRemove, 1)
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
- function ____exports.runInNFrames(self, func, frames)
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.queuedFunctionTuples, tuple)
60
+ __TS__ArrayPush(v.run.queuedGameFunctionTuples, tuple)
45
61
  end
46
- FEATURE_NAME = "run in N frames"
47
- initialized = false
48
- v = {dontSave = true, run = {queuedFunctionTuples = {}}}
49
- function ____exports.runInNFramesInit(self, mod)
50
- initialized = true
51
- saveDataManager(nil, "runInNFrames", v)
52
- mod:AddCallback(ModCallbacks.MC_POST_UPDATE, postUpdate)
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.runNextFrame(self, func)
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.runInNFrames(nil, func, 1)
84
+ ____exports.runInNRenderFrames(nil, func, 1)
60
85
  end
61
86
  return ____exports
@@ -81,7 +81,10 @@ NON_ALIVE_NPCS_TYPE_VARIANT = __TS__New(
81
81
  )
82
82
  NON_ALIVE_NPCS_TYPE_VARIANT_SUBTYPE = __TS__New(
83
83
  Set,
84
- {(((tostring(EntityType.ENTITY_CHARGER) .. ".") .. 0) .. ".") .. 1}
84
+ {
85
+ (((tostring(EntityType.ENTITY_CHARGER) .. ".") .. 0) .. ".") .. 1,
86
+ (((tostring(EntityType.ENTITY_MOTHER) .. ".") .. 0) .. ".") .. 1
87
+ }
85
88
  )
86
89
  function ____exports.fireProjectiles(self, npc, position, velocity, projectilesMode, projectileParams)
87
90
  if projectilesMode == nil then
@@ -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(roomType: RoomType): int[];
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.
@@ -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, roomType)
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 == roomType end
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 { runInNFrames, runNextFrame } from "./features/runInNFrames";
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 runInNFrames = ____runInNFrames.runInNFrames
60
- local runNextFrame = ____runInNFrames.runNextFrame
61
- ____exports.runInNFrames = runInNFrames
62
- ____exports.runNextFrame = runNextFrame
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.26",
3
+ "version": "1.2.30",
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.338",
29
+ "isaac-typescript-definitions": "^1.0.341",
30
30
  "isaacscript-lint": "^1.0.79",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.11",