isaacscript-common 21.8.0 → 21.8.1

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.
@@ -5922,9 +5922,9 @@ export declare function getRandomIndexFromWeightedArray<T>(weightedArray: Weight
5922
5922
  export declare function getRandomInt(min: int, max: int, seedOrRNG?: Seed | RNG, exceptions?: int[] | readonly int[]): int;
5923
5923
 
5924
5924
  /**
5925
- * Helper function to get a random item pool. This is as simple as getting a random value from the
5926
- * `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the Greed
5927
- * Mode item pools should be excluded if not playing in Greed Mode.
5925
+ * Helper function to get a random item pool. This is not as simple as getting a random value from
5926
+ * the `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the
5927
+ * Greed Mode item pools should be excluded if not playing in Greed Mode.
5928
5928
  */
5929
5929
  export declare function getRandomItemPool(): ItemPoolType;
5930
5930
 
@@ -13553,11 +13553,11 @@ declare class RunInNFrames extends Feature {
13553
13553
  * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_IN_N_FRAMES`.
13554
13554
  *
13555
13555
  * @param func The function to run.
13556
- * @param gameFrames The amount of game frames to wait before running the function.
13556
+ * @param numGameFrames The amount of game frames to wait before running the function.
13557
13557
  * @param cancelIfRoomChanges Optional. Whether or not to cancel running the function if a new
13558
13558
  * room is loaded in the interim. Default is false.
13559
13559
  */
13560
- runInNGameFrames(func: () => void, gameFrames: int, cancelIfRoomChanges?: boolean): void;
13560
+ runInNGameFrames(func: () => void, numGameFrames: int, cancelIfRoomChanges?: boolean): void;
13561
13561
  /**
13562
13562
  * Supply a function to run N render frames from now in the `POST_RENDER` callback.
13563
13563
  *
@@ -13571,11 +13571,11 @@ declare class RunInNFrames extends Feature {
13571
13571
  * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_IN_N_FRAMES`.
13572
13572
  *
13573
13573
  * @param func The function to run.
13574
- * @param renderFrames The amount of render frames to wait before running the function.
13574
+ * @param numRenderFrames The amount of render frames to wait before running the function.
13575
13575
  * @param cancelIfRoomChanges Optional. Whether or not to cancel running the function if a new
13576
13576
  * room is loaded in the interim. Default is false.
13577
13577
  */
13578
- runInNRenderFrames(func: () => void, renderFrames: int, cancelIfRoomChanges?: boolean): void;
13578
+ runInNRenderFrames(func: () => void, numRenderFrames: int, cancelIfRoomChanges?: boolean): void;
13579
13579
  /**
13580
13580
  * Supply a function to run on the next `POST_UPDATE` callback.
13581
13581
  *
@@ -13640,13 +13640,13 @@ declare class RunInNFrames extends Feature {
13640
13640
  * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_IN_N_FRAMES`.
13641
13641
  *
13642
13642
  * @param func The function to repeatedly run on an interval.
13643
- * @param gameFrames The amount of game frames to wait between each run.
13643
+ * @param numGameFrames The amount of game frames to wait between each run.
13644
13644
  * @param runImmediately Whether or not to execute the function right now before waiting for the
13645
13645
  * interval.
13646
13646
  * @param cancelIfRoomChanges Optional. Whether or not to cancel running the function if a new
13647
13647
  * room is loaded in the interim. Default is false.
13648
13648
  */
13649
- setIntervalGameFrames(func: () => boolean, gameFrames: int, runImmediately: boolean, cancelIfRoomChanges?: boolean): void;
13649
+ setIntervalGameFrames(func: () => boolean, numGameFrames: int, runImmediately: boolean, cancelIfRoomChanges?: boolean): void;
13650
13650
  /**
13651
13651
  * Supply a function to be repeatedly run on an interval of N render frames in the `POST_RENDER`
13652
13652
  * callback. The function will continue to be fired until `false` is returned from the function.
@@ -13661,13 +13661,13 @@ declare class RunInNFrames extends Feature {
13661
13661
  * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_IN_N_FRAMES`.
13662
13662
  *
13663
13663
  * @param func The function to repeatedly run on an interval.
13664
- * @param renderFrames The amount of game frames to wait between each run.
13664
+ * @param numRenderFrames The amount of game frames to wait between each run.
13665
13665
  * @param runImmediately Whether or not to execute the function right now before waiting for the
13666
13666
  * interval.
13667
13667
  * @param cancelIfRoomChanges Optional. Whether or not to cancel running the function if a new
13668
13668
  * room is loaded in the interim. Default is false.
13669
13669
  */
13670
- setIntervalRenderFrames(func: () => boolean, renderFrames: int, runImmediately: boolean, cancelIfRoomChanges?: boolean): void;
13670
+ setIntervalRenderFrames(func: () => boolean, numRenderFrames: int, runImmediately: boolean, cancelIfRoomChanges?: boolean): void;
13671
13671
  }
13672
13672
 
13673
13673
  /**
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 21.8.0
3
+ isaacscript-common 21.8.1
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -32294,9 +32294,9 @@ local ____run = require("src.functions.run")
32294
32294
  local restart = ____run.restart
32295
32295
  local ____Feature = require("src.classes.private.Feature")
32296
32296
  local Feature = ____Feature.Feature
32297
- function checkExecuteQueuedFunctions(self, functionTuples, frameCount, newNumRoomsEntered)
32297
+ function checkExecuteQueuedFunctions(self, queuedFunctions, frameCount, newNumRoomsEntered)
32298
32298
  local firingFunctions = __TS__ArrayFilter(
32299
- functionTuples,
32299
+ queuedFunctions,
32300
32300
  function(____, ____bindingPattern0)
32301
32301
  local frameCountToFire
32302
32302
  frameCountToFire = ____bindingPattern0.frameCountToFire
@@ -32310,12 +32310,12 @@ function checkExecuteQueuedFunctions(self, functionTuples, frameCount, newNumRoo
32310
32310
  if not cancelIfRoomChanges or numRoomsEntered == newNumRoomsEntered then
32311
32311
  func(nil)
32312
32312
  end
32313
- arrayRemoveInPlace(nil, functionTuples, firingFunction)
32313
+ arrayRemoveInPlace(nil, queuedFunctions, firingFunction)
32314
32314
  end
32315
32315
  end
32316
- function checkExecuteIntervalFunctions(self, functionTuples, frameCount, newNumRoomsEntered)
32316
+ function checkExecuteIntervalFunctions(self, intervalFunctions, frameCount, newNumRoomsEntered)
32317
32317
  local firingFunctions = __TS__ArrayFilter(
32318
- functionTuples,
32318
+ intervalFunctions,
32319
32319
  function(____, ____bindingPattern0)
32320
32320
  local frameCountToFire
32321
32321
  frameCountToFire = ____bindingPattern0.frameCountToFire
@@ -32331,7 +32331,7 @@ function checkExecuteIntervalFunctions(self, functionTuples, frameCount, newNumR
32331
32331
  if not cancelIfRoomChanges or numRoomsEntered == newNumRoomsEntered then
32332
32332
  returnValue = func(nil)
32333
32333
  end
32334
- arrayRemoveInPlace(nil, functionTuples, firingFunction)
32334
+ arrayRemoveInPlace(nil, intervalFunctions, firingFunction)
32335
32335
  if returnValue then
32336
32336
  local newIntervalFunction = {
32337
32337
  func = func,
@@ -32340,7 +32340,7 @@ function checkExecuteIntervalFunctions(self, functionTuples, frameCount, newNumR
32340
32340
  cancelIfRoomChanges = cancelIfRoomChanges,
32341
32341
  numIntervalFrames = numIntervalFrames
32342
32342
  }
32343
- functionTuples[#functionTuples + 1] = newIntervalFunction
32343
+ intervalFunctions[#intervalFunctions + 1] = newIntervalFunction
32344
32344
  end
32345
32345
  end
32346
32346
  end
@@ -32373,24 +32373,24 @@ function RunInNFrames.prototype.restartNextRenderFrame(self, character)
32373
32373
  restart(nil, character)
32374
32374
  end)
32375
32375
  end
32376
- function RunInNFrames.prototype.runInNGameFrames(self, func, gameFrames, cancelIfRoomChanges)
32376
+ function RunInNFrames.prototype.runInNGameFrames(self, func, numGameFrames, cancelIfRoomChanges)
32377
32377
  if cancelIfRoomChanges == nil then
32378
32378
  cancelIfRoomChanges = false
32379
32379
  end
32380
32380
  local gameFrameCount = game:GetFrameCount()
32381
32381
  local numRoomsEntered = self.roomHistory:getNumRoomsEntered()
32382
- local frameCountToFire = gameFrameCount + gameFrames
32382
+ local frameCountToFire = gameFrameCount + numGameFrames
32383
32383
  local queuedFunction = {func = func, frameCountToFire = frameCountToFire, numRoomsEntered = numRoomsEntered, cancelIfRoomChanges = cancelIfRoomChanges}
32384
32384
  local ____self_v_run_queuedGameFunctions_0 = self.v.run.queuedGameFunctions
32385
32385
  ____self_v_run_queuedGameFunctions_0[#____self_v_run_queuedGameFunctions_0 + 1] = queuedFunction
32386
32386
  end
32387
- function RunInNFrames.prototype.runInNRenderFrames(self, func, renderFrames, cancelIfRoomChanges)
32387
+ function RunInNFrames.prototype.runInNRenderFrames(self, func, numRenderFrames, cancelIfRoomChanges)
32388
32388
  if cancelIfRoomChanges == nil then
32389
32389
  cancelIfRoomChanges = false
32390
32390
  end
32391
32391
  local renderFrameCount = Isaac.GetFrameCount()
32392
32392
  local numRoomsEntered = self.roomHistory:getNumRoomsEntered()
32393
- local frameCountToFire = renderFrameCount + renderFrames
32393
+ local frameCountToFire = renderFrameCount + numRenderFrames
32394
32394
  local queuedFunction = {func = func, frameCountToFire = frameCountToFire, numRoomsEntered = numRoomsEntered, cancelIfRoomChanges = cancelIfRoomChanges}
32395
32395
  local ____self_v_run_queuedRenderFunctions_1 = self.v.run.queuedRenderFunctions
32396
32396
  ____self_v_run_queuedRenderFunctions_1[#____self_v_run_queuedRenderFunctions_1 + 1] = queuedFunction
@@ -32407,43 +32407,49 @@ function RunInNFrames.prototype.runNextRenderFrame(self, func, cancelIfRoomChang
32407
32407
  end
32408
32408
  self:runInNRenderFrames(func, 1, cancelIfRoomChanges)
32409
32409
  end
32410
- function RunInNFrames.prototype.setIntervalGameFrames(self, func, gameFrames, runImmediately, cancelIfRoomChanges)
32410
+ function RunInNFrames.prototype.setIntervalGameFrames(self, func, numGameFrames, runImmediately, cancelIfRoomChanges)
32411
32411
  if cancelIfRoomChanges == nil then
32412
32412
  cancelIfRoomChanges = false
32413
32413
  end
32414
+ if runImmediately then
32415
+ local returnValue = func(nil)
32416
+ if not returnValue then
32417
+ return
32418
+ end
32419
+ end
32414
32420
  local gameFrameCount = game:GetFrameCount()
32415
32421
  local numRoomsEntered = self.roomHistory:getNumRoomsEntered()
32416
32422
  local intervalFunction = {
32417
32423
  func = func,
32418
- frameCountToFire = gameFrameCount + gameFrames,
32424
+ frameCountToFire = gameFrameCount + numGameFrames,
32419
32425
  numRoomsEntered = numRoomsEntered,
32420
32426
  cancelIfRoomChanges = cancelIfRoomChanges,
32421
- numIntervalFrames = gameFrames
32427
+ numIntervalFrames = numGameFrames
32422
32428
  }
32423
32429
  local ____self_v_run_intervalGameFunctions_2 = self.v.run.intervalGameFunctions
32424
32430
  ____self_v_run_intervalGameFunctions_2[#____self_v_run_intervalGameFunctions_2 + 1] = intervalFunction
32425
- if runImmediately then
32426
- func(nil)
32427
- end
32428
32431
  end
32429
- function RunInNFrames.prototype.setIntervalRenderFrames(self, func, renderFrames, runImmediately, cancelIfRoomChanges)
32432
+ function RunInNFrames.prototype.setIntervalRenderFrames(self, func, numRenderFrames, runImmediately, cancelIfRoomChanges)
32430
32433
  if cancelIfRoomChanges == nil then
32431
32434
  cancelIfRoomChanges = false
32432
32435
  end
32436
+ if runImmediately then
32437
+ local returnValue = func(nil)
32438
+ if not returnValue then
32439
+ return
32440
+ end
32441
+ end
32433
32442
  local renderFrameCount = Isaac.GetFrameCount()
32434
32443
  local numRoomsEntered = self.roomHistory:getNumRoomsEntered()
32435
32444
  local intervalFunction = {
32436
32445
  func = func,
32437
- frameCountToFire = renderFrameCount + renderFrames,
32446
+ frameCountToFire = renderFrameCount + numRenderFrames,
32438
32447
  numRoomsEntered = numRoomsEntered,
32439
32448
  cancelIfRoomChanges = cancelIfRoomChanges,
32440
- numIntervalFrames = renderFrames
32449
+ numIntervalFrames = numRenderFrames
32441
32450
  }
32442
- local ____self_v_run_intervalGameFunctions_3 = self.v.run.intervalGameFunctions
32443
- ____self_v_run_intervalGameFunctions_3[#____self_v_run_intervalGameFunctions_3 + 1] = intervalFunction
32444
- if runImmediately then
32445
- func(nil)
32446
- end
32451
+ local ____self_v_run_intervalRenderFunctions_3 = self.v.run.intervalRenderFunctions
32452
+ ____self_v_run_intervalRenderFunctions_3[#____self_v_run_intervalRenderFunctions_3 + 1] = intervalFunction
32447
32453
  end
32448
32454
  __TS__Decorate({Exported}, RunInNFrames.prototype, "restartNextRenderFrame", true)
32449
32455
  __TS__Decorate({Exported}, RunInNFrames.prototype, "runInNGameFrames", true)
@@ -28,11 +28,11 @@ export declare class RunInNFrames extends Feature {
28
28
  * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_IN_N_FRAMES`.
29
29
  *
30
30
  * @param func The function to run.
31
- * @param gameFrames The amount of game frames to wait before running the function.
31
+ * @param numGameFrames The amount of game frames to wait before running the function.
32
32
  * @param cancelIfRoomChanges Optional. Whether or not to cancel running the function if a new
33
33
  * room is loaded in the interim. Default is false.
34
34
  */
35
- runInNGameFrames(func: () => void, gameFrames: int, cancelIfRoomChanges?: boolean): void;
35
+ runInNGameFrames(func: () => void, numGameFrames: int, cancelIfRoomChanges?: boolean): void;
36
36
  /**
37
37
  * Supply a function to run N render frames from now in the `POST_RENDER` callback.
38
38
  *
@@ -46,11 +46,11 @@ export declare class RunInNFrames extends Feature {
46
46
  * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_IN_N_FRAMES`.
47
47
  *
48
48
  * @param func The function to run.
49
- * @param renderFrames The amount of render frames to wait before running the function.
49
+ * @param numRenderFrames The amount of render frames to wait before running the function.
50
50
  * @param cancelIfRoomChanges Optional. Whether or not to cancel running the function if a new
51
51
  * room is loaded in the interim. Default is false.
52
52
  */
53
- runInNRenderFrames(func: () => void, renderFrames: int, cancelIfRoomChanges?: boolean): void;
53
+ runInNRenderFrames(func: () => void, numRenderFrames: int, cancelIfRoomChanges?: boolean): void;
54
54
  /**
55
55
  * Supply a function to run on the next `POST_UPDATE` callback.
56
56
  *
@@ -115,13 +115,13 @@ export declare class RunInNFrames extends Feature {
115
115
  * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_IN_N_FRAMES`.
116
116
  *
117
117
  * @param func The function to repeatedly run on an interval.
118
- * @param gameFrames The amount of game frames to wait between each run.
118
+ * @param numGameFrames The amount of game frames to wait between each run.
119
119
  * @param runImmediately Whether or not to execute the function right now before waiting for the
120
120
  * interval.
121
121
  * @param cancelIfRoomChanges Optional. Whether or not to cancel running the function if a new
122
122
  * room is loaded in the interim. Default is false.
123
123
  */
124
- setIntervalGameFrames(func: () => boolean, gameFrames: int, runImmediately: boolean, cancelIfRoomChanges?: boolean): void;
124
+ setIntervalGameFrames(func: () => boolean, numGameFrames: int, runImmediately: boolean, cancelIfRoomChanges?: boolean): void;
125
125
  /**
126
126
  * Supply a function to be repeatedly run on an interval of N render frames in the `POST_RENDER`
127
127
  * callback. The function will continue to be fired until `false` is returned from the function.
@@ -136,12 +136,12 @@ export declare class RunInNFrames extends Feature {
136
136
  * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_IN_N_FRAMES`.
137
137
  *
138
138
  * @param func The function to repeatedly run on an interval.
139
- * @param renderFrames The amount of game frames to wait between each run.
139
+ * @param numRenderFrames The amount of game frames to wait between each run.
140
140
  * @param runImmediately Whether or not to execute the function right now before waiting for the
141
141
  * interval.
142
142
  * @param cancelIfRoomChanges Optional. Whether or not to cancel running the function if a new
143
143
  * room is loaded in the interim. Default is false.
144
144
  */
145
- setIntervalRenderFrames(func: () => boolean, renderFrames: int, runImmediately: boolean, cancelIfRoomChanges?: boolean): void;
145
+ setIntervalRenderFrames(func: () => boolean, numRenderFrames: int, runImmediately: boolean, cancelIfRoomChanges?: boolean): void;
146
146
  }
147
147
  //# sourceMappingURL=RunInNFrames.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RunInNFrames.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/RunInNFrames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAMvE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAwBhD,qBAAa,YAAa,SAAQ,OAAO;IAYvB,gBAAgB,QAAO,OAAO,CAAU;IAExD,OAAO,CAAC,WAAW,CAAc;IAoBjC,OAAO,CAAC,UAAU,CAchB;IAGF,OAAO,CAAC,UAAU,CAchB;IAEF;;;;;;;;OAQG;IAEI,sBAAsB,CAAC,SAAS,CAAC,EAAE,UAAU,GAAG,IAAI;IAM3D;;;;;;;;;;;;;;;;OAgBG;IAEI,gBAAgB,CACrB,IAAI,EAAE,MAAM,IAAI,EAChB,UAAU,EAAE,GAAG,EACf,mBAAmB,UAAQ,GAC1B,IAAI;IAcP;;;;;;;;;;;;;;;;OAgBG;IAEI,kBAAkB,CACvB,IAAI,EAAE,MAAM,IAAI,EAChB,YAAY,EAAE,GAAG,EACjB,mBAAmB,UAAQ,GAC1B,IAAI;IAcP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IAEI,gBAAgB,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,mBAAmB,UAAQ,GAAG,IAAI;IAI5E;;;;;;;;;;;;;OAaG;IAEI,kBAAkB,CACvB,IAAI,EAAE,MAAM,IAAI,EAChB,mBAAmB,UAAQ,GAC1B,IAAI;IAIP;;;;;;;;;;;;;;;;;;;OAmBG;IAEI,qBAAqB,CAC1B,IAAI,EAAE,MAAM,OAAO,EACnB,UAAU,EAAE,GAAG,EACf,cAAc,EAAE,OAAO,EACvB,mBAAmB,UAAQ,GAC1B,IAAI;IAkBP;;;;;;;;;;;;;;;;;;;OAmBG;IAEI,uBAAuB,CAC5B,IAAI,EAAE,MAAM,OAAO,EACnB,YAAY,EAAE,GAAG,EACjB,cAAc,EAAE,OAAO,EACvB,mBAAmB,UAAQ,GAC1B,IAAI;CAiBR"}
1
+ {"version":3,"file":"RunInNFrames.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/RunInNFrames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAMvE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAqBhD,qBAAa,YAAa,SAAQ,OAAO;IAYvB,gBAAgB,QAAO,OAAO,CAAU;IAExD,OAAO,CAAC,WAAW,CAAc;IAoBjC,OAAO,CAAC,UAAU,CAchB;IAGF,OAAO,CAAC,UAAU,CAchB;IAEF;;;;;;;;OAQG;IAEI,sBAAsB,CAAC,SAAS,CAAC,EAAE,UAAU,GAAG,IAAI;IAM3D;;;;;;;;;;;;;;;;OAgBG;IAEI,gBAAgB,CACrB,IAAI,EAAE,MAAM,IAAI,EAChB,aAAa,EAAE,GAAG,EAClB,mBAAmB,UAAQ,GAC1B,IAAI;IAcP;;;;;;;;;;;;;;;;OAgBG;IAEI,kBAAkB,CACvB,IAAI,EAAE,MAAM,IAAI,EAChB,eAAe,EAAE,GAAG,EACpB,mBAAmB,UAAQ,GAC1B,IAAI;IAcP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IAEI,gBAAgB,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,mBAAmB,UAAQ,GAAG,IAAI;IAI5E;;;;;;;;;;;;;OAaG;IAEI,kBAAkB,CACvB,IAAI,EAAE,MAAM,IAAI,EAChB,mBAAmB,UAAQ,GAC1B,IAAI;IAIP;;;;;;;;;;;;;;;;;;;OAmBG;IAEI,qBAAqB,CAC1B,IAAI,EAAE,MAAM,OAAO,EACnB,aAAa,EAAE,GAAG,EAClB,cAAc,EAAE,OAAO,EACvB,mBAAmB,UAAQ,GAC1B,IAAI;IAqBP;;;;;;;;;;;;;;;;;;;OAmBG;IAEI,uBAAuB,CAC5B,IAAI,EAAE,MAAM,OAAO,EACnB,eAAe,EAAE,GAAG,EACpB,cAAc,EAAE,OAAO,EACvB,mBAAmB,UAAQ,GAC1B,IAAI;CAoBR"}
@@ -19,9 +19,9 @@ local ____run = require("src.functions.run")
19
19
  local restart = ____run.restart
20
20
  local ____Feature = require("src.classes.private.Feature")
21
21
  local Feature = ____Feature.Feature
22
- function checkExecuteQueuedFunctions(self, functionTuples, frameCount, newNumRoomsEntered)
22
+ function checkExecuteQueuedFunctions(self, queuedFunctions, frameCount, newNumRoomsEntered)
23
23
  local firingFunctions = __TS__ArrayFilter(
24
- functionTuples,
24
+ queuedFunctions,
25
25
  function(____, ____bindingPattern0)
26
26
  local frameCountToFire
27
27
  frameCountToFire = ____bindingPattern0.frameCountToFire
@@ -35,12 +35,12 @@ function checkExecuteQueuedFunctions(self, functionTuples, frameCount, newNumRoo
35
35
  if not cancelIfRoomChanges or numRoomsEntered == newNumRoomsEntered then
36
36
  func(nil)
37
37
  end
38
- arrayRemoveInPlace(nil, functionTuples, firingFunction)
38
+ arrayRemoveInPlace(nil, queuedFunctions, firingFunction)
39
39
  end
40
40
  end
41
- function checkExecuteIntervalFunctions(self, functionTuples, frameCount, newNumRoomsEntered)
41
+ function checkExecuteIntervalFunctions(self, intervalFunctions, frameCount, newNumRoomsEntered)
42
42
  local firingFunctions = __TS__ArrayFilter(
43
- functionTuples,
43
+ intervalFunctions,
44
44
  function(____, ____bindingPattern0)
45
45
  local frameCountToFire
46
46
  frameCountToFire = ____bindingPattern0.frameCountToFire
@@ -56,7 +56,7 @@ function checkExecuteIntervalFunctions(self, functionTuples, frameCount, newNumR
56
56
  if not cancelIfRoomChanges or numRoomsEntered == newNumRoomsEntered then
57
57
  returnValue = func(nil)
58
58
  end
59
- arrayRemoveInPlace(nil, functionTuples, firingFunction)
59
+ arrayRemoveInPlace(nil, intervalFunctions, firingFunction)
60
60
  if returnValue then
61
61
  local newIntervalFunction = {
62
62
  func = func,
@@ -65,7 +65,7 @@ function checkExecuteIntervalFunctions(self, functionTuples, frameCount, newNumR
65
65
  cancelIfRoomChanges = cancelIfRoomChanges,
66
66
  numIntervalFrames = numIntervalFrames
67
67
  }
68
- functionTuples[#functionTuples + 1] = newIntervalFunction
68
+ intervalFunctions[#intervalFunctions + 1] = newIntervalFunction
69
69
  end
70
70
  end
71
71
  end
@@ -98,24 +98,24 @@ function RunInNFrames.prototype.restartNextRenderFrame(self, character)
98
98
  restart(nil, character)
99
99
  end)
100
100
  end
101
- function RunInNFrames.prototype.runInNGameFrames(self, func, gameFrames, cancelIfRoomChanges)
101
+ function RunInNFrames.prototype.runInNGameFrames(self, func, numGameFrames, cancelIfRoomChanges)
102
102
  if cancelIfRoomChanges == nil then
103
103
  cancelIfRoomChanges = false
104
104
  end
105
105
  local gameFrameCount = game:GetFrameCount()
106
106
  local numRoomsEntered = self.roomHistory:getNumRoomsEntered()
107
- local frameCountToFire = gameFrameCount + gameFrames
107
+ local frameCountToFire = gameFrameCount + numGameFrames
108
108
  local queuedFunction = {func = func, frameCountToFire = frameCountToFire, numRoomsEntered = numRoomsEntered, cancelIfRoomChanges = cancelIfRoomChanges}
109
109
  local ____self_v_run_queuedGameFunctions_0 = self.v.run.queuedGameFunctions
110
110
  ____self_v_run_queuedGameFunctions_0[#____self_v_run_queuedGameFunctions_0 + 1] = queuedFunction
111
111
  end
112
- function RunInNFrames.prototype.runInNRenderFrames(self, func, renderFrames, cancelIfRoomChanges)
112
+ function RunInNFrames.prototype.runInNRenderFrames(self, func, numRenderFrames, cancelIfRoomChanges)
113
113
  if cancelIfRoomChanges == nil then
114
114
  cancelIfRoomChanges = false
115
115
  end
116
116
  local renderFrameCount = Isaac.GetFrameCount()
117
117
  local numRoomsEntered = self.roomHistory:getNumRoomsEntered()
118
- local frameCountToFire = renderFrameCount + renderFrames
118
+ local frameCountToFire = renderFrameCount + numRenderFrames
119
119
  local queuedFunction = {func = func, frameCountToFire = frameCountToFire, numRoomsEntered = numRoomsEntered, cancelIfRoomChanges = cancelIfRoomChanges}
120
120
  local ____self_v_run_queuedRenderFunctions_1 = self.v.run.queuedRenderFunctions
121
121
  ____self_v_run_queuedRenderFunctions_1[#____self_v_run_queuedRenderFunctions_1 + 1] = queuedFunction
@@ -132,43 +132,49 @@ function RunInNFrames.prototype.runNextRenderFrame(self, func, cancelIfRoomChang
132
132
  end
133
133
  self:runInNRenderFrames(func, 1, cancelIfRoomChanges)
134
134
  end
135
- function RunInNFrames.prototype.setIntervalGameFrames(self, func, gameFrames, runImmediately, cancelIfRoomChanges)
135
+ function RunInNFrames.prototype.setIntervalGameFrames(self, func, numGameFrames, runImmediately, cancelIfRoomChanges)
136
136
  if cancelIfRoomChanges == nil then
137
137
  cancelIfRoomChanges = false
138
138
  end
139
+ if runImmediately then
140
+ local returnValue = func(nil)
141
+ if not returnValue then
142
+ return
143
+ end
144
+ end
139
145
  local gameFrameCount = game:GetFrameCount()
140
146
  local numRoomsEntered = self.roomHistory:getNumRoomsEntered()
141
147
  local intervalFunction = {
142
148
  func = func,
143
- frameCountToFire = gameFrameCount + gameFrames,
149
+ frameCountToFire = gameFrameCount + numGameFrames,
144
150
  numRoomsEntered = numRoomsEntered,
145
151
  cancelIfRoomChanges = cancelIfRoomChanges,
146
- numIntervalFrames = gameFrames
152
+ numIntervalFrames = numGameFrames
147
153
  }
148
154
  local ____self_v_run_intervalGameFunctions_2 = self.v.run.intervalGameFunctions
149
155
  ____self_v_run_intervalGameFunctions_2[#____self_v_run_intervalGameFunctions_2 + 1] = intervalFunction
150
- if runImmediately then
151
- func(nil)
152
- end
153
156
  end
154
- function RunInNFrames.prototype.setIntervalRenderFrames(self, func, renderFrames, runImmediately, cancelIfRoomChanges)
157
+ function RunInNFrames.prototype.setIntervalRenderFrames(self, func, numRenderFrames, runImmediately, cancelIfRoomChanges)
155
158
  if cancelIfRoomChanges == nil then
156
159
  cancelIfRoomChanges = false
157
160
  end
161
+ if runImmediately then
162
+ local returnValue = func(nil)
163
+ if not returnValue then
164
+ return
165
+ end
166
+ end
158
167
  local renderFrameCount = Isaac.GetFrameCount()
159
168
  local numRoomsEntered = self.roomHistory:getNumRoomsEntered()
160
169
  local intervalFunction = {
161
170
  func = func,
162
- frameCountToFire = renderFrameCount + renderFrames,
171
+ frameCountToFire = renderFrameCount + numRenderFrames,
163
172
  numRoomsEntered = numRoomsEntered,
164
173
  cancelIfRoomChanges = cancelIfRoomChanges,
165
- numIntervalFrames = renderFrames
174
+ numIntervalFrames = numRenderFrames
166
175
  }
167
- local ____self_v_run_intervalGameFunctions_3 = self.v.run.intervalGameFunctions
168
- ____self_v_run_intervalGameFunctions_3[#____self_v_run_intervalGameFunctions_3 + 1] = intervalFunction
169
- if runImmediately then
170
- func(nil)
171
- end
176
+ local ____self_v_run_intervalRenderFunctions_3 = self.v.run.intervalRenderFunctions
177
+ ____self_v_run_intervalRenderFunctions_3[#____self_v_run_intervalRenderFunctions_3 + 1] = intervalFunction
172
178
  end
173
179
  __TS__Decorate({Exported}, RunInNFrames.prototype, "restartNextRenderFrame", true)
174
180
  __TS__Decorate({Exported}, RunInNFrames.prototype, "runInNGameFrames", true)
@@ -1,8 +1,8 @@
1
1
  import { ItemPoolType } from "isaac-typescript-definitions";
2
2
  /**
3
- * Helper function to get a random item pool. This is as simple as getting a random value from the
4
- * `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the Greed
5
- * Mode item pools should be excluded if not playing in Greed Mode.
3
+ * Helper function to get a random item pool. This is not as simple as getting a random value from
4
+ * the `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the
5
+ * Greed Mode item pools should be excluded if not playing in Greed Mode.
6
6
  */
7
7
  export declare function getRandomItemPool(): ItemPoolType;
8
8
  //# sourceMappingURL=itemPool.d.ts.map
@@ -53,9 +53,9 @@ __TS__SparseArrayPush(
53
53
  table.unpack(FAKE_ITEM_POOL_TYPES)
54
54
  )
55
55
  local GREED_MODE_ITEM_POOL_TYPES = ____arrayRemove_3(__TS__SparseArraySpread(____array_2))
56
- --- Helper function to get a random item pool. This is as simple as getting a random value from the
57
- -- `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the Greed
58
- -- Mode item pools should be excluded if not playing in Greed Mode.
56
+ --- Helper function to get a random item pool. This is not as simple as getting a random value from
57
+ -- the `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the
58
+ -- Greed Mode item pools should be excluded if not playing in Greed Mode.
59
59
  function ____exports.getRandomItemPool(self)
60
60
  local itemPoolTypes = isGreedMode(nil) and GREED_MODE_ITEM_POOL_TYPES or NORMAL_MODE_ITEM_POOL_TYPES
61
61
  return getRandomArrayElement(nil, itemPoolTypes)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "21.8.0",
3
+ "version": "21.8.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -20,11 +20,8 @@ interface QueuedFunction {
20
20
  *
21
21
  * The return value is whether or not to continue the function from firing.
22
22
  */
23
- interface IntervalFunction {
23
+ interface IntervalFunction extends QueuedFunction {
24
24
  func: () => boolean;
25
- frameCountToFire: int;
26
- numRoomsEntered: int;
27
- cancelIfRoomChanges: boolean;
28
25
  numIntervalFrames: int;
29
26
  }
30
27
 
@@ -124,20 +121,20 @@ export class RunInNFrames extends Feature {
124
121
  * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_IN_N_FRAMES`.
125
122
  *
126
123
  * @param func The function to run.
127
- * @param gameFrames The amount of game frames to wait before running the function.
124
+ * @param numGameFrames The amount of game frames to wait before running the function.
128
125
  * @param cancelIfRoomChanges Optional. Whether or not to cancel running the function if a new
129
126
  * room is loaded in the interim. Default is false.
130
127
  */
131
128
  @Exported
132
129
  public runInNGameFrames(
133
130
  func: () => void,
134
- gameFrames: int,
131
+ numGameFrames: int,
135
132
  cancelIfRoomChanges = false,
136
133
  ): void {
137
134
  const gameFrameCount = game.GetFrameCount();
138
135
  const numRoomsEntered = this.roomHistory.getNumRoomsEntered();
139
136
 
140
- const frameCountToFire = gameFrameCount + gameFrames;
137
+ const frameCountToFire = gameFrameCount + numGameFrames;
141
138
  const queuedFunction: QueuedFunction = {
142
139
  func,
143
140
  frameCountToFire,
@@ -160,20 +157,20 @@ export class RunInNFrames extends Feature {
160
157
  * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_IN_N_FRAMES`.
161
158
  *
162
159
  * @param func The function to run.
163
- * @param renderFrames The amount of render frames to wait before running the function.
160
+ * @param numRenderFrames The amount of render frames to wait before running the function.
164
161
  * @param cancelIfRoomChanges Optional. Whether or not to cancel running the function if a new
165
162
  * room is loaded in the interim. Default is false.
166
163
  */
167
164
  @Exported
168
165
  public runInNRenderFrames(
169
166
  func: () => void,
170
- renderFrames: int,
167
+ numRenderFrames: int,
171
168
  cancelIfRoomChanges = false,
172
169
  ): void {
173
170
  const renderFrameCount = Isaac.GetFrameCount();
174
171
  const numRoomsEntered = this.roomHistory.getNumRoomsEntered();
175
172
 
176
- const frameCountToFire = renderFrameCount + renderFrames;
173
+ const frameCountToFire = renderFrameCount + numRenderFrames;
177
174
  const queuedFunction: QueuedFunction = {
178
175
  func,
179
176
  frameCountToFire,
@@ -258,7 +255,7 @@ export class RunInNFrames extends Feature {
258
255
  * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_IN_N_FRAMES`.
259
256
  *
260
257
  * @param func The function to repeatedly run on an interval.
261
- * @param gameFrames The amount of game frames to wait between each run.
258
+ * @param numGameFrames The amount of game frames to wait between each run.
262
259
  * @param runImmediately Whether or not to execute the function right now before waiting for the
263
260
  * interval.
264
261
  * @param cancelIfRoomChanges Optional. Whether or not to cancel running the function if a new
@@ -267,25 +264,28 @@ export class RunInNFrames extends Feature {
267
264
  @Exported
268
265
  public setIntervalGameFrames(
269
266
  func: () => boolean,
270
- gameFrames: int,
267
+ numGameFrames: int,
271
268
  runImmediately: boolean,
272
269
  cancelIfRoomChanges = false,
273
270
  ): void {
271
+ if (runImmediately) {
272
+ const returnValue = func();
273
+ if (!returnValue) {
274
+ return;
275
+ }
276
+ }
277
+
274
278
  const gameFrameCount = game.GetFrameCount();
275
279
  const numRoomsEntered = this.roomHistory.getNumRoomsEntered();
276
280
 
277
281
  const intervalFunction: IntervalFunction = {
278
282
  func,
279
- frameCountToFire: gameFrameCount + gameFrames,
283
+ frameCountToFire: gameFrameCount + numGameFrames,
280
284
  numRoomsEntered,
281
285
  cancelIfRoomChanges,
282
- numIntervalFrames: gameFrames,
286
+ numIntervalFrames: numGameFrames,
283
287
  };
284
288
  this.v.run.intervalGameFunctions.push(intervalFunction);
285
-
286
- if (runImmediately) {
287
- func();
288
- }
289
289
  }
290
290
 
291
291
  /**
@@ -302,7 +302,7 @@ export class RunInNFrames extends Feature {
302
302
  * In order to use this function, you must upgrade your mod with `ISCFeature.RUN_IN_N_FRAMES`.
303
303
  *
304
304
  * @param func The function to repeatedly run on an interval.
305
- * @param renderFrames The amount of game frames to wait between each run.
305
+ * @param numRenderFrames The amount of game frames to wait between each run.
306
306
  * @param runImmediately Whether or not to execute the function right now before waiting for the
307
307
  * interval.
308
308
  * @param cancelIfRoomChanges Optional. Whether or not to cancel running the function if a new
@@ -311,34 +311,37 @@ export class RunInNFrames extends Feature {
311
311
  @Exported
312
312
  public setIntervalRenderFrames(
313
313
  func: () => boolean,
314
- renderFrames: int,
314
+ numRenderFrames: int,
315
315
  runImmediately: boolean,
316
316
  cancelIfRoomChanges = false,
317
317
  ): void {
318
+ if (runImmediately) {
319
+ const returnValue = func();
320
+ if (!returnValue) {
321
+ return;
322
+ }
323
+ }
324
+
318
325
  const renderFrameCount = Isaac.GetFrameCount();
319
326
  const numRoomsEntered = this.roomHistory.getNumRoomsEntered();
320
327
 
321
328
  const intervalFunction: IntervalFunction = {
322
329
  func,
323
- frameCountToFire: renderFrameCount + renderFrames,
330
+ frameCountToFire: renderFrameCount + numRenderFrames,
324
331
  numRoomsEntered,
325
332
  cancelIfRoomChanges,
326
- numIntervalFrames: renderFrames,
333
+ numIntervalFrames: numRenderFrames,
327
334
  };
328
- this.v.run.intervalGameFunctions.push(intervalFunction);
329
-
330
- if (runImmediately) {
331
- func();
332
- }
335
+ this.v.run.intervalRenderFunctions.push(intervalFunction);
333
336
  }
334
337
  }
335
338
 
336
339
  function checkExecuteQueuedFunctions(
337
- functionTuples: QueuedFunction[],
340
+ queuedFunctions: QueuedFunction[],
338
341
  frameCount: int,
339
342
  newNumRoomsEntered: int,
340
343
  ) {
341
- const firingFunctions = functionTuples.filter(
344
+ const firingFunctions = queuedFunctions.filter(
342
345
  ({ frameCountToFire }) => frameCount >= frameCountToFire,
343
346
  );
344
347
 
@@ -349,16 +352,16 @@ function checkExecuteQueuedFunctions(
349
352
  func();
350
353
  }
351
354
 
352
- arrayRemoveInPlace(functionTuples, firingFunction);
355
+ arrayRemoveInPlace(queuedFunctions, firingFunction);
353
356
  }
354
357
  }
355
358
 
356
359
  function checkExecuteIntervalFunctions(
357
- functionTuples: IntervalFunction[],
360
+ intervalFunctions: IntervalFunction[],
358
361
  frameCount: int,
359
362
  newNumRoomsEntered: int,
360
363
  ) {
361
- const firingFunctions = functionTuples.filter(
364
+ const firingFunctions = intervalFunctions.filter(
362
365
  ({ frameCountToFire }) => frameCount >= frameCountToFire,
363
366
  );
364
367
 
@@ -371,7 +374,7 @@ function checkExecuteIntervalFunctions(
371
374
  returnValue = func();
372
375
  }
373
376
 
374
- arrayRemoveInPlace(functionTuples, firingFunction);
377
+ arrayRemoveInPlace(intervalFunctions, firingFunction);
375
378
 
376
379
  // Queue the next interval (as long as the function did not return false).
377
380
  if (returnValue) {
@@ -382,7 +385,7 @@ function checkExecuteIntervalFunctions(
382
385
  cancelIfRoomChanges,
383
386
  numIntervalFrames,
384
387
  };
385
- functionTuples.push(newIntervalFunction);
388
+ intervalFunctions.push(newIntervalFunction);
386
389
  }
387
390
  }
388
391
  }
@@ -38,9 +38,9 @@ const GREED_MODE_ITEM_POOL_TYPES: readonly ItemPoolType[] = arrayRemove(
38
38
  );
39
39
 
40
40
  /**
41
- * Helper function to get a random item pool. This is as simple as getting a random value from the
42
- * `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the Greed
43
- * Mode item pools should be excluded if not playing in Greed Mode.
41
+ * Helper function to get a random item pool. This is not as simple as getting a random value from
42
+ * the `ItemPoolType` enum, since `ItemPoolType.SHELL_GAME` (7) is not a real item pool and the
43
+ * Greed Mode item pools should be excluded if not playing in Greed Mode.
44
44
  */
45
45
  export function getRandomItemPool(): ItemPoolType {
46
46
  const itemPoolTypes = isGreedMode()