isaacscript-common 55.1.0 → 55.2.0

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.
Files changed (52) hide show
  1. package/dist/index.rollup.d.ts +26 -1
  2. package/dist/isaacscript-common.lua +2607 -2575
  3. package/dist/src/classes/callbacks/PostNewRoomEarly.lua +2 -2
  4. package/dist/src/classes/features/callbackLogic/CustomRevive.d.ts.map +1 -1
  5. package/dist/src/classes/features/callbackLogic/CustomRevive.lua +1 -2
  6. package/dist/src/classes/features/other/CustomStages.lua +2 -2
  7. package/dist/src/classes/features/other/ExtraConsoleCommands.lua +2 -2
  8. package/dist/src/classes/features/other/Pause.lua +2 -2
  9. package/dist/src/classes/features/other/TaintedLazarusPlayers.lua +2 -2
  10. package/dist/src/classes/features/other/saveDataManager/loadFromDisk.d.ts.map +1 -1
  11. package/dist/src/classes/features/other/saveDataManager/loadFromDisk.lua +1 -2
  12. package/dist/src/classes/features/other/saveDataManager/restoreDefaults.lua +2 -2
  13. package/dist/src/functions/hex.lua +2 -2
  14. package/dist/src/functions/jsonHelpers.lua +2 -2
  15. package/dist/src/functions/log.d.ts +7 -0
  16. package/dist/src/functions/log.d.ts.map +1 -1
  17. package/dist/src/functions/log.lua +8 -0
  18. package/dist/src/functions/logMisc.d.ts +0 -7
  19. package/dist/src/functions/logMisc.d.ts.map +1 -1
  20. package/dist/src/functions/logMisc.lua +0 -9
  21. package/dist/src/functions/rng.d.ts.map +1 -1
  22. package/dist/src/functions/rng.lua +4 -1
  23. package/dist/src/functions/roomShape.d.ts +5 -0
  24. package/dist/src/functions/roomShape.d.ts.map +1 -1
  25. package/dist/src/functions/roomShape.lua +7 -0
  26. package/dist/src/functions/rooms.d.ts +10 -0
  27. package/dist/src/functions/rooms.d.ts.map +1 -1
  28. package/dist/src/functions/rooms.lua +14 -2
  29. package/dist/src/functions/stage.d.ts +8 -1
  30. package/dist/src/functions/stage.d.ts.map +1 -1
  31. package/dist/src/functions/stage.lua +5 -0
  32. package/dist/src/sets/bigRoomShapesSet.d.ts +3 -0
  33. package/dist/src/sets/bigRoomShapesSet.d.ts.map +1 -0
  34. package/dist/src/sets/bigRoomShapesSet.lua +17 -0
  35. package/package.json +1 -1
  36. package/src/classes/callbacks/PostNewRoomEarly.ts +1 -1
  37. package/src/classes/features/callbackLogic/CustomRevive.ts +1 -2
  38. package/src/classes/features/other/CustomStages.ts +1 -1
  39. package/src/classes/features/other/ExtraConsoleCommands.ts +1 -1
  40. package/src/classes/features/other/Pause.ts +1 -1
  41. package/src/classes/features/other/TaintedLazarusPlayers.ts +1 -1
  42. package/src/classes/features/other/saveDataManager/loadFromDisk.ts +1 -2
  43. package/src/classes/features/other/saveDataManager/restoreDefaults.ts +1 -1
  44. package/src/functions/hex.ts +1 -1
  45. package/src/functions/jsonHelpers.ts +1 -1
  46. package/src/functions/log.ts +11 -0
  47. package/src/functions/logMisc.ts +1 -12
  48. package/src/functions/rng.ts +4 -2
  49. package/src/functions/roomShape.ts +9 -0
  50. package/src/functions/rooms.ts +18 -1
  51. package/src/functions/stage.ts +8 -1
  52. package/src/sets/bigRoomShapesSet.ts +12 -0
@@ -22,7 +22,7 @@ import { getEntityID } from "./entities";
22
22
  import { getEnumEntries } from "./enums";
23
23
  import { hasFlag } from "./flag";
24
24
  import { getIsaacAPIClassName } from "./isaacAPIClass";
25
- import { log, logAndPrint } from "./log";
25
+ import { log } from "./log";
26
26
  import { getPlayerHealth } from "./playerHealth";
27
27
  import { getEffectsList, getPlayerName } from "./players";
28
28
  import { getRoomData, getRoomGridIndex, getRoomListIndex } from "./roomData";
@@ -128,17 +128,6 @@ export function logEntityID(this: void, entity: Entity): void {
128
128
  log(`Logging entity: ${entityID}`);
129
129
  }
130
130
 
131
- /**
132
- * Helper function to log an error message and also print it to the console for better visibility.
133
- *
134
- * This is useful in situations where using the `error` function would be dangerous (since it
135
- * prevents all of the subsequent code in the callback from running).
136
- */
137
- export function logError(this: void, msg: string): void {
138
- const errorMsg = `Error: ${msg}`;
139
- logAndPrint(errorMsg);
140
- }
141
-
142
131
  /** Helper function for logging every flag that is turned on. Useful when debugging. */
143
132
  export function logFlags<T extends BitFlag | BitFlag128>(
144
133
  this: void,
@@ -2,6 +2,7 @@ import type { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
2
  import { game } from "../core/cachedClasses";
3
3
  import { SerializationBrand } from "../enums/private/SerializationBrand";
4
4
  import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
5
+ import { logError } from "./log";
5
6
  import { getNumbersFromTable, tableHasKeys } from "./table";
6
7
  import { isTable } from "./types";
7
8
  import { assertDefined } from "./utils";
@@ -155,8 +156,9 @@ export function setAllRNGToStartSeed(object: unknown): void {
155
156
  /** Helper function to set a seed to an RNG object using Blade's recommended shift index. */
156
157
  export function setSeed(rng: RNG, seed: Seed): void {
157
158
  if (seed === 0) {
158
- error(
159
- "You cannot set an RNG object to a seed of 0, or the game will crash.",
159
+ seed = getRandomSeed();
160
+ logError(
161
+ "Failed to set a RNG object to a seed of 0. Using a random value instead.",
160
162
  );
161
163
  }
162
164
 
@@ -10,6 +10,7 @@ import { ROOM_SHAPE_TO_GRID_WIDTH } from "../objects/roomShapeToGridWidth";
10
10
  import { ROOM_SHAPE_TO_TOP_LEFT_POSITION } from "../objects/roomShapeToTopLeftPosition";
11
11
  import { ROOM_SHAPE_VOLUMES } from "../objects/roomShapeVolumes";
12
12
  import { L_ROOM_SHAPES_SET } from "../sets/LRoomShapesSet";
13
+ import { BIG_ROOM_SHAPES_SET } from "../sets/bigRoomShapesSet";
13
14
  import { NARROW_ROOM_SHAPES_SET } from "../sets/narrowRoomShapesSet";
14
15
 
15
16
  /**
@@ -109,6 +110,14 @@ export function getRoomShapeWidth(roomShape: RoomShape): int {
109
110
  return ROOM_SHAPE_TO_GRID_WIDTH[roomShape];
110
111
  }
111
112
 
113
+ /**
114
+ * Helper function to detect if the provided room shape is big. Specifically, this is all 1x2 rooms,
115
+ * 2x2 rooms, and L rooms.
116
+ */
117
+ export function isBigRoomShape(roomShape: RoomShape): boolean {
118
+ return BIG_ROOM_SHAPES_SET.has(roomShape);
119
+ }
120
+
112
121
  export function isLRoomShape(roomShape: RoomShape): boolean {
113
122
  return L_ROOM_SHAPES_SET.has(roomShape);
114
123
  }
@@ -45,7 +45,7 @@ import {
45
45
  getRoomDescriptorReadOnly,
46
46
  getRoomGridIndex,
47
47
  } from "./roomData";
48
- import { isLRoomShape } from "./roomShape";
48
+ import { isBigRoomShape, isLRoomShape } from "./roomShape";
49
49
  import { reloadRoom } from "./roomTransition";
50
50
  import { getGotoCommand } from "./stage";
51
51
  import { asNumber } from "./types";
@@ -318,6 +318,15 @@ export function inBeastRoom(): boolean {
318
318
  return isBeastRoom(roomData);
319
319
  }
320
320
 
321
+ /**
322
+ * Helper function to detect if the current room is big. Specifically, this is all 1x2 rooms, 2x2
323
+ * rooms, and L rooms.
324
+ */
325
+ export function inBigRoom(): boolean {
326
+ const roomData = getRoomData();
327
+ return isBigRoom(roomData);
328
+ }
329
+
321
330
  /**
322
331
  * Helper function to check if the current room is the Boss Room for a particular boss. This will
323
332
  * only work for bosses that have dedicated boss rooms in the "00.special rooms.stb" file.
@@ -601,6 +610,14 @@ export function isBeastRoom(roomData: RoomConfig): boolean {
601
610
  );
602
611
  }
603
612
 
613
+ /**
614
+ * Helper function to detect if the provided room is big. Specifically, this is all 1x2 rooms, 2x2
615
+ * rooms, and L rooms.
616
+ */
617
+ export function isBigRoom(roomData: RoomConfig): boolean {
618
+ return isBigRoomShape(roomData.Shape);
619
+ }
620
+
604
621
  /**
605
622
  * Helper function to check if the provided room is the Boss Room for a particular boss. This will
606
623
  * only work for bosses that have dedicated boss rooms in the "00.special rooms.stb" file.
@@ -181,7 +181,14 @@ export function getStageType(): StageType {
181
181
  return level.GetStageType();
182
182
  }
183
183
 
184
- /** Helper function to directly warp to a specific stage using the "stage" console command. */
184
+ /**
185
+ * Helper function to directly warp to a specific stage using the "stage" console command.
186
+ *
187
+ * Note that if you use this function on game frame 0, it will confuse the
188
+ * `POST_GAME_STARTED_REORDERED`, `POST_NEW_LEVEL_REORDERED`, and `POST_NEW_ROOM_REORDERED` custom
189
+ * callbacks. If you are using the function in this situation, remember to call the
190
+ * `reorderedCallbacksSetStage` function.
191
+ */
185
192
  export function goToStage(stage: LevelStage, stageType: StageType): void {
186
193
  const stageTypeLetterSuffix = stageTypeToLetter(stageType);
187
194
  const command = `stage ${stage}${stageTypeLetterSuffix}`;
@@ -0,0 +1,12 @@
1
+ import { RoomShape } from "isaac-typescript-definitions";
2
+ import { ReadonlySet } from "../types/ReadonlySet";
3
+
4
+ export const BIG_ROOM_SHAPES_SET = new ReadonlySet<RoomShape>([
5
+ RoomShape.SHAPE_1x2, // 4
6
+ RoomShape.SHAPE_2x1, // 6
7
+ RoomShape.SHAPE_2x2, // 8
8
+ RoomShape.LTL, // 9
9
+ RoomShape.LTR, // 10
10
+ RoomShape.LBL, // 11
11
+ RoomShape.LBR, // 12
12
+ ]);