isaacscript-common 6.8.0 → 6.10.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.
Files changed (122) hide show
  1. package/dist/features/customStage/customStageGridEntities.lua +2 -2
  2. package/dist/features/customStage/exports.d.ts.map +1 -1
  3. package/dist/features/customStage/exports.lua +5 -4
  4. package/dist/features/customStage/init.d.ts.map +1 -1
  5. package/dist/features/customStage/init.lua +12 -3
  6. package/dist/features/customStage/streakText.d.ts +4 -2
  7. package/dist/features/customStage/streakText.d.ts.map +1 -1
  8. package/dist/features/customStage/streakText.lua +216 -15
  9. package/dist/features/customStage/v.d.ts +4 -2
  10. package/dist/features/customStage/v.d.ts.map +1 -1
  11. package/dist/features/customStage/v.lua +9 -1
  12. package/dist/features/customStage/versusScreen.d.ts +1 -1
  13. package/dist/features/customStage/versusScreen.d.ts.map +1 -1
  14. package/dist/features/customStage/versusScreen.lua +2 -5
  15. package/dist/features/extraConsoleCommands/init.lua +1 -0
  16. package/dist/features/extraConsoleCommands/listCommands.d.ts +8 -0
  17. package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
  18. package/dist/features/extraConsoleCommands/listCommands.lua +13 -0
  19. package/dist/features/saveDataManager/exports.d.ts.map +1 -1
  20. package/dist/features/saveDataManager/exports.lua +2 -4
  21. package/dist/features/saveDataManager/load.d.ts +1 -1
  22. package/dist/features/saveDataManager/load.d.ts.map +1 -1
  23. package/dist/features/saveDataManager/main.d.ts.map +1 -1
  24. package/dist/features/saveDataManager/main.lua +0 -1
  25. package/dist/features/saveDataManager/maps.d.ts +3 -3
  26. package/dist/features/saveDataManager/maps.d.ts.map +1 -1
  27. package/dist/features/saveDataManager/maps.lua +1 -4
  28. package/dist/features/saveDataManager/merge.d.ts +2 -2
  29. package/dist/features/saveDataManager/merge.d.ts.map +1 -1
  30. package/dist/features/saveDataManager/merge.lua +3 -3
  31. package/dist/features/saveDataManager/save.d.ts +1 -1
  32. package/dist/features/saveDataManager/save.d.ts.map +1 -1
  33. package/dist/features/saveDataManager/save.lua +1 -2
  34. package/dist/features/saveDataManager/{serializationBrand.d.ts → serializationBrands.d.ts} +1 -1
  35. package/dist/features/saveDataManager/serializationBrands.d.ts.map +1 -0
  36. package/dist/features/saveDataManager/{serializationBrand.lua → serializationBrands.lua} +0 -0
  37. package/dist/functions/array.d.ts.map +1 -1
  38. package/dist/functions/color.d.ts +1 -1
  39. package/dist/functions/color.d.ts.map +1 -1
  40. package/dist/functions/deepCopy.d.ts +1 -1
  41. package/dist/functions/deepCopy.lua +55 -36
  42. package/dist/functions/deepCopyTests.lua +20 -17
  43. package/dist/functions/entities.d.ts +1 -1
  44. package/dist/functions/entities.d.ts.map +1 -1
  45. package/dist/functions/input.d.ts.map +1 -1
  46. package/dist/functions/input.lua +8 -10
  47. package/dist/functions/jsonHelpers.d.ts +1 -1
  48. package/dist/functions/jsonHelpers.d.ts.map +1 -1
  49. package/dist/functions/kColor.d.ts +1 -1
  50. package/dist/functions/kColor.d.ts.map +1 -1
  51. package/dist/functions/log.d.ts +1 -1
  52. package/dist/functions/log.d.ts.map +1 -1
  53. package/dist/functions/log.lua +3 -1
  54. package/dist/functions/mergeTests.d.ts +2 -2
  55. package/dist/functions/mergeTests.lua +2 -2
  56. package/dist/functions/playerIndex.d.ts +1 -1
  57. package/dist/functions/playerIndex.lua +1 -1
  58. package/dist/functions/rng.d.ts +1 -1
  59. package/dist/functions/rng.d.ts.map +1 -1
  60. package/dist/functions/run.d.ts +8 -0
  61. package/dist/functions/run.d.ts.map +1 -1
  62. package/dist/functions/run.lua +15 -0
  63. package/dist/functions/table.d.ts +9 -9
  64. package/dist/functions/table.d.ts.map +1 -1
  65. package/dist/functions/table.lua +23 -21
  66. package/dist/functions/types.d.ts +1 -1
  67. package/dist/functions/types.d.ts.map +1 -1
  68. package/dist/functions/vector.d.ts +1 -1
  69. package/dist/functions/vector.d.ts.map +1 -1
  70. package/dist/interfaces/SaveData.d.ts +1 -1
  71. package/dist/interfaces/private/TSTLClassMetatable.d.ts +1 -1
  72. package/dist/interfaces/private/TSTLClassMetatable.d.ts.map +1 -1
  73. package/dist/lualib_bundle.lua +38 -7
  74. package/dist/types/PlayerIndex.d.ts +3 -2
  75. package/dist/types/PlayerIndex.d.ts.map +1 -1
  76. package/dist/types/private/IsaacAPIClass.d.ts +1 -1
  77. package/dist/types/private/IsaacAPIClass.d.ts.map +1 -1
  78. package/dist/types/private/SerializedIsaacAPIClass.d.ts +1 -1
  79. package/dist/types/private/SerializedIsaacAPIClass.d.ts.map +1 -1
  80. package/dist/types/private/TSTLClass.d.ts +1 -1
  81. package/dist/types/private/TSTLClass.d.ts.map +1 -1
  82. package/package.json +2 -2
  83. package/src/features/customStage/customStageGridEntities.ts +4 -4
  84. package/src/features/customStage/exports.ts +5 -3
  85. package/src/features/customStage/init.ts +19 -7
  86. package/src/features/customStage/streakText.ts +284 -19
  87. package/src/features/customStage/v.ts +6 -1
  88. package/src/features/customStage/versusScreen.ts +2 -5
  89. package/src/features/extraConsoleCommands/init.ts +1 -0
  90. package/src/features/extraConsoleCommands/listCommands.ts +14 -0
  91. package/src/features/saveDataManager/exports.ts +3 -8
  92. package/src/features/saveDataManager/load.ts +2 -3
  93. package/src/features/saveDataManager/main.ts +4 -5
  94. package/src/features/saveDataManager/maps.ts +3 -3
  95. package/src/features/saveDataManager/merge.ts +11 -11
  96. package/src/features/saveDataManager/save.ts +6 -6
  97. package/src/features/saveDataManager/{serializationBrand.ts → serializationBrands.ts} +0 -0
  98. package/src/functions/array.ts +2 -4
  99. package/src/functions/color.ts +3 -3
  100. package/src/functions/deepCopy.ts +77 -40
  101. package/src/functions/deepCopyTests.ts +45 -28
  102. package/src/functions/entities.ts +7 -7
  103. package/src/functions/input.ts +7 -8
  104. package/src/functions/isaacAPIClass.ts +3 -3
  105. package/src/functions/jsonHelpers.ts +3 -3
  106. package/src/functions/kColor.ts +3 -3
  107. package/src/functions/log.ts +7 -4
  108. package/src/functions/mergeTests.ts +24 -24
  109. package/src/functions/playerIndex.ts +1 -1
  110. package/src/functions/rng.ts +3 -3
  111. package/src/functions/run.ts +14 -0
  112. package/src/functions/table.ts +25 -23
  113. package/src/functions/tstlClass.ts +1 -1
  114. package/src/functions/types.ts +3 -1
  115. package/src/functions/vector.ts +3 -3
  116. package/src/interfaces/SaveData.ts +1 -1
  117. package/src/interfaces/private/TSTLClassMetatable.ts +1 -1
  118. package/src/types/PlayerIndex.ts +3 -2
  119. package/src/types/private/IsaacAPIClass.ts +1 -1
  120. package/src/types/private/SerializedIsaacAPIClass.ts +1 -1
  121. package/src/types/private/TSTLClass.ts +1 -1
  122. package/dist/features/saveDataManager/serializationBrand.d.ts.map +0 -1
@@ -2,7 +2,7 @@ import * as json from "json";
2
2
  import { logError } from "./log";
3
3
 
4
4
  function tryDecode(this: void, jsonString: string) {
5
- return json.decode(jsonString) as LuaTable;
5
+ return json.decode(jsonString) as LuaMap;
6
6
  }
7
7
 
8
8
  function tryEncode(this: void, luaTable: unknown) {
@@ -17,12 +17,12 @@ function tryEncode(this: void, luaTable: unknown) {
17
17
  * continue in cases where users have no current save data or have manually removed their existing
18
18
  * save data.)
19
19
  */
20
- export function jsonDecode(jsonString: string): LuaTable<AnyNotNil, unknown> {
20
+ export function jsonDecode(jsonString: string): LuaMap<AnyNotNil, unknown> {
21
21
  const [ok, luaTableOrErrMsg] = pcall(tryDecode, jsonString);
22
22
  if (!ok) {
23
23
  // Instead of throwing an error, continue execution of the callback.
24
24
  logError(`Failed to convert the JSON string to a Lua table: ${jsonString}`);
25
- return new LuaTable();
25
+ return new LuaMap();
26
26
  }
27
27
 
28
28
  return luaTableOrErrMsg;
@@ -4,7 +4,7 @@ import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
4
4
  import { copyValuesToTable, getNumbersFromTable, tableHasKeys } from "./table";
5
5
  import { isTable } from "./types";
6
6
 
7
- type SerializedKColor = LuaTable<string, unknown> & {
7
+ type SerializedKColor = LuaMap<string, unknown> & {
8
8
  readonly __serializedKColorBrand: symbol;
9
9
  };
10
10
 
@@ -53,7 +53,7 @@ export function copyKColor(
53
53
  );
54
54
  }
55
55
 
56
- const kColorTable = new LuaTable<string, unknown>();
56
+ const kColorTable = new LuaMap<string, unknown>();
57
57
  copyValuesToTable(kColor, KEYS, kColorTable);
58
58
  kColorTable.set(SerializationBrand.K_COLOR, "");
59
59
  return kColorTable as SerializedKColor;
@@ -67,7 +67,7 @@ export function copyKColor(
67
67
  }
68
68
 
69
69
  const [r, g, b, a] = getNumbersFromTable(
70
- kColor as LuaTable<string, unknown>,
70
+ kColor as LuaMap<string, unknown>,
71
71
  OBJECT_NAME,
72
72
  ...KEYS,
73
73
  );
@@ -640,6 +640,7 @@ export function logTable(
640
640
  return;
641
641
  }
642
642
 
643
+ let numElements = 0;
643
644
  iterateTableInOrder(luaTable, (key, value) => {
644
645
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
645
646
  log(`${indentation}${key} --> ${value}`);
@@ -653,12 +654,14 @@ export function logTable(
653
654
  logTable(value, parentTables + 1);
654
655
  }
655
656
  }
657
+
658
+ numElements++;
656
659
  });
657
660
 
658
661
  // Put it in an IIFE so that the it will show as "func" instead of "logTable" and align with the
659
662
  // other text.
660
663
  (() => {
661
- log(`${indentation}The size of the table was: ${luaTable.length()}`);
664
+ log(`${indentation}The size of the table was: ${numElements}`);
662
665
  })();
663
666
  }
664
667
 
@@ -668,8 +671,8 @@ export function logTable(
668
671
  */
669
672
  export function logTableDifferences<K, V>(
670
673
  this: void,
671
- table1: LuaTable<K, V>,
672
- table2: LuaTable<K, V>,
674
+ table1: LuaMap<K, V>,
675
+ table2: LuaMap<K, V>,
673
676
  ): void {
674
677
  log("Comparing two Lua tables:");
675
678
 
@@ -725,7 +728,7 @@ export function logUserdata(this: void, userdata: unknown): void {
725
728
  }
726
729
 
727
730
  const metatable = getmetatable(userdata) as
728
- | LuaTable<AnyNotNil, unknown>
731
+ | LuaMap<AnyNotNil, unknown>
729
732
  | undefined;
730
733
  if (metatable === undefined) {
731
734
  log("Userdata: [no metatable]");
@@ -8,8 +8,8 @@ import { isSerializedIsaacAPIClass } from "./serialization";
8
8
  import { copyVector, isVector } from "./vector";
9
9
 
10
10
  /**
11
- * Run the suite of tests that prove that the "merge" helper function works properly. (This function
12
- * is not exported but is used internally in the save data manager.)
11
+ * Run the suite of tests that prove that the "merge" function works properly. (This function is not
12
+ * exported but is used internally in the save data manager.)
13
13
  *
14
14
  * This function is only useful if you are troubleshooting the save data manager.
15
15
  */
@@ -37,10 +37,10 @@ function oldTableHasUpdatedValue() {
37
37
  const newValue = "baz";
38
38
  const oldTable = {
39
39
  foo: oldValue,
40
- } as unknown as LuaTable<AnyNotNil, unknown>;
40
+ } as unknown as LuaMap<AnyNotNil, unknown>;
41
41
  const newTable = {
42
42
  foo: newValue,
43
- } as unknown as LuaTable<AnyNotNil, unknown>;
43
+ } as unknown as LuaMap<AnyNotNil, unknown>;
44
44
 
45
45
  merge(oldTable, newTable, "oldTableHasUpdatedValue");
46
46
 
@@ -56,10 +56,10 @@ function newTableHasSameValue() {
56
56
  const newValue = "baz";
57
57
  const oldTable = {
58
58
  foo: oldValue,
59
- } as unknown as LuaTable<AnyNotNil, unknown>;
59
+ } as unknown as LuaMap<AnyNotNil, unknown>;
60
60
  const newTable = {
61
61
  foo: newValue,
62
- } as unknown as LuaTable<AnyNotNil, unknown>;
62
+ } as unknown as LuaMap<AnyNotNil, unknown>;
63
63
 
64
64
  merge(oldTable, newTable, "newTableHasSameValue");
65
65
 
@@ -74,10 +74,10 @@ function oldTableHasUpdatedValueFromNull() {
74
74
  const newValue = "baz";
75
75
  const oldTable = {
76
76
  foo: null as string | null,
77
- } as unknown as LuaTable<AnyNotNil, unknown>;
77
+ } as unknown as LuaMap<AnyNotNil, unknown>;
78
78
  const newTable = {
79
79
  foo: newValue,
80
- } as unknown as LuaTable<AnyNotNil, unknown>;
80
+ } as unknown as LuaMap<AnyNotNil, unknown>;
81
81
 
82
82
  merge(oldTable, newTable, "oldTableHasUpdatedValueFromNull");
83
83
 
@@ -109,13 +109,13 @@ function oldTableHasFilledChildTable() {
109
109
  const newValue = "baz";
110
110
  const oldTable = {
111
111
  foo: null as Foo | null,
112
- } as unknown as LuaTable<AnyNotNil, unknown>;
112
+ } as unknown as LuaMap<AnyNotNil, unknown>;
113
113
  const foo: Foo = {
114
114
  bar: newValue,
115
115
  };
116
116
  const newTable = {
117
117
  foo,
118
- } as unknown as LuaTable<AnyNotNil, unknown>;
118
+ } as unknown as LuaMap<AnyNotNil, unknown>;
119
119
 
120
120
  merge(oldTable, newTable, "oldTableHasFilledChildTable");
121
121
 
@@ -148,8 +148,8 @@ function oldTableHasFilledMap() {
148
148
  const serializedSaveData = deepCopy(saveData, SerializationType.SERIALIZE);
149
149
 
150
150
  merge(
151
- v as unknown as LuaTable,
152
- serializedSaveData as LuaTable,
151
+ v as unknown as LuaMap,
152
+ serializedSaveData as LuaMap,
153
153
  "oldTableHasFilledMap",
154
154
  );
155
155
 
@@ -216,8 +216,8 @@ function oldTableHasFilledDefaultMap() {
216
216
  const serializedSaveData = deepCopy(saveData, SerializationType.SERIALIZE);
217
217
 
218
218
  merge(
219
- v as unknown as LuaTable,
220
- serializedSaveData as LuaTable,
219
+ v as unknown as LuaMap,
220
+ serializedSaveData as LuaMap,
221
221
  "oldTableHasFilledDefaultMap",
222
222
  );
223
223
 
@@ -278,13 +278,13 @@ function oldTableHasVector() {
278
278
  const newValue = Vector(x, y);
279
279
  const oldTable = {
280
280
  foo: null as Foo | null,
281
- } as unknown as LuaTable<AnyNotNil, unknown>;
281
+ } as unknown as LuaMap<AnyNotNil, unknown>;
282
282
  const foo: Foo = {
283
283
  bar: newValue,
284
284
  };
285
285
  const newTable = {
286
286
  foo,
287
- } as unknown as LuaTable<AnyNotNil, unknown>;
287
+ } as unknown as LuaMap<AnyNotNil, unknown>;
288
288
 
289
289
  merge(oldTable, newTable, "oldTableHasVector");
290
290
 
@@ -319,18 +319,18 @@ function oldTableHasVectorSerialized() {
319
319
  const newValue = Vector(x, y);
320
320
  const oldTable = {
321
321
  foo: null as Foo | null,
322
- } as unknown as LuaTable<AnyNotNil, unknown>;
322
+ } as unknown as LuaMap<AnyNotNil, unknown>;
323
323
  const foo: Foo = {
324
324
  bar: newValue,
325
325
  };
326
326
  const newTable = {
327
327
  foo,
328
- } as unknown as LuaTable<AnyNotNil, unknown>;
328
+ } as unknown as LuaMap<AnyNotNil, unknown>;
329
329
  const newTableSerialized = deepCopy(
330
330
  newTable,
331
331
  SerializationType.SERIALIZE,
332
332
  "oldTableHasVectorSerialized",
333
- ) as LuaTable<AnyNotNil, unknown>;
333
+ ) as LuaMap<AnyNotNil, unknown>;
334
334
 
335
335
  merge(oldTable, newTableSerialized, "oldTableHasVectorSerialized");
336
336
 
@@ -366,13 +366,13 @@ function oldTableHasRNG() {
366
366
  const newValue = newRNG(seed);
367
367
  const oldTable = {
368
368
  foo: null as Foo | null,
369
- } as unknown as LuaTable<AnyNotNil, unknown>;
369
+ } as unknown as LuaMap<AnyNotNil, unknown>;
370
370
  const foo: Foo = {
371
371
  bar: newValue,
372
372
  };
373
373
  const newTable = {
374
374
  foo,
375
- } as unknown as LuaTable<AnyNotNil, unknown>;
375
+ } as unknown as LuaMap<AnyNotNil, unknown>;
376
376
 
377
377
  merge(oldTable, newTable, "oldTableHasRNG");
378
378
 
@@ -403,18 +403,18 @@ function oldTableHasRNGSerialized() {
403
403
  const newValue = newRNG(seed);
404
404
  const oldTable = {
405
405
  foo: null as Foo | null,
406
- } as unknown as LuaTable<AnyNotNil, unknown>;
406
+ } as unknown as LuaMap<AnyNotNil, unknown>;
407
407
  const foo: Foo = {
408
408
  bar: newValue,
409
409
  };
410
410
  const newTable = {
411
411
  foo,
412
- } as unknown as LuaTable<AnyNotNil, unknown>;
412
+ } as unknown as LuaMap<AnyNotNil, unknown>;
413
413
  const newTableSerialized = deepCopy(
414
414
  newTable,
415
415
  SerializationType.SERIALIZE,
416
416
  "oldTableHasRNGSerialized",
417
- ) as LuaTable<AnyNotNil, unknown>;
417
+ ) as LuaMap<AnyNotNil, unknown>;
418
418
 
419
419
  merge(oldTable, newTableSerialized, "oldTableHasRNGSerialized");
420
420
 
@@ -64,7 +64,7 @@ export function getPlayerFromIndex(
64
64
  * this is not desired, pass true for the `differentiateForgottenAndSoul` argument, and the RNG of
65
65
  * Spoon Bender (3) will be used for The Soul.
66
66
  *
67
- * Also note that this index doesn't work in the `POST_PLAYER_INIT` function for players 2 through
67
+ * Also note that this index does not work in the `POST_PLAYER_INIT` function for players 2 through
68
68
  * 4. With that said, in almost all cases, you should be lazy-initializing your data structures in
69
69
  * other callbacks, so this should not be an issue.
70
70
  */
@@ -5,7 +5,7 @@ import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
5
5
  import { getNumbersFromTable, tableHasKeys } from "./table";
6
6
  import { isTable } from "./types";
7
7
 
8
- type SerializedRNG = LuaTable<string, unknown> & {
8
+ type SerializedRNG = LuaMap<string, unknown> & {
9
9
  readonly __serializedRNGBrand: symbol;
10
10
  };
11
11
 
@@ -63,7 +63,7 @@ export function copyRNG(
63
63
  }
64
64
 
65
65
  const seed = rng.GetSeed();
66
- const rngTable = new LuaTable<string, unknown>();
66
+ const rngTable = new LuaMap<string, unknown>();
67
67
  rngTable.set("seed", seed);
68
68
  rngTable.set(SerializationBrand.RNG, "");
69
69
  return rngTable as SerializedRNG;
@@ -77,7 +77,7 @@ export function copyRNG(
77
77
  }
78
78
 
79
79
  const [seedNumber] = getNumbersFromTable(
80
- rng as LuaTable<string, unknown>,
80
+ rng as LuaMap<string, unknown>,
81
81
  OBJECT_NAME,
82
82
  ...KEYS,
83
83
  );
@@ -1,6 +1,7 @@
1
1
  import { Challenge, PlayerType } from "isaac-typescript-definitions";
2
2
  import { game } from "../cachedClasses";
3
3
  import { FIRST_CHARACTER } from "../constantsFirstLast";
4
+ import { runNextRenderFrame } from "../features/runInNFrames";
4
5
  import { log } from "./log";
5
6
 
6
7
  /**
@@ -42,6 +43,19 @@ export function restart(character?: PlayerType): void {
42
43
  Isaac.ExecuteCommand(command);
43
44
  }
44
45
 
46
+ /**
47
+ * Helper function to restart on the next render frame. Useful because it is impossible to restart
48
+ * the game inside of the `POST_NEW_ROOM`, `POST_NEW_LEVEL`, or `POST_GAME_STARTED` callbacks when a
49
+ * run is first starting.
50
+ *
51
+ * You can optionally specify a `PlayerType` to restart the game as that character.
52
+ */
53
+ export function restartNextRenderFrame(character?: PlayerType): void {
54
+ runNextRenderFrame(() => {
55
+ restart(character);
56
+ });
57
+ }
58
+
45
59
  /**
46
60
  * Helper function to change the run status to that of an unseeded run with a new random seed.
47
61
  *
@@ -1,12 +1,12 @@
1
1
  import { isBoolean, isNumber, isString } from "./types";
2
2
 
3
3
  /**
4
- * In a Map, you can use the `clear` method to delete every element. However, in a LuaTable, the
4
+ * In a `Map`, you can use the `clear` method to delete every element. However, in a `LuaMap`, the
5
5
  * `clear` method does not exist. Use this helper function as a drop-in replacement for this.
6
6
  */
7
- export function clearTable(luaTable: LuaTable): void {
8
- for (const [key] of pairs(luaTable)) {
9
- luaTable.delete(key);
7
+ export function clearTable(luaMap: LuaMap): void {
8
+ for (const [key] of pairs(luaMap)) {
9
+ luaMap.delete(key);
10
10
  }
11
11
  }
12
12
 
@@ -14,13 +14,13 @@ export function clearTable(luaTable: LuaTable): void {
14
14
  export function copyValuesToTable(
15
15
  object: unknown,
16
16
  keys: string[],
17
- luaTable: LuaTable<string, unknown>,
17
+ luaMap: LuaMap<string, unknown>,
18
18
  ): void {
19
- const otherTable = object as LuaTable<string, string | number>;
19
+ const otherTable = object as LuaMap<string, string | number>;
20
20
 
21
21
  for (const key of keys) {
22
22
  const value = otherTable.get(key);
23
- luaTable.set(key, value);
23
+ luaMap.set(key, value);
24
24
  }
25
25
  }
26
26
 
@@ -31,13 +31,13 @@ export function copyValuesToTable(
31
31
  * This function is variadic, meaning that you can specify N arguments to get N values.
32
32
  */
33
33
  export function getBooleansFromTable(
34
- luaTable: LuaTable<string, unknown>,
34
+ luaMap: LuaMap<string, unknown>,
35
35
  objectName: string,
36
36
  ...keys: string[]
37
37
  ): boolean[] {
38
38
  const booleans: boolean[] = [];
39
39
  for (const key of keys) {
40
- const value = luaTable.get(key);
40
+ const value = luaMap.get(key);
41
41
  if (value === undefined) {
42
42
  error(
43
43
  `Failed to find a value for "${key}" in a table representing a "${objectName}" object.`,
@@ -63,13 +63,13 @@ export function getBooleansFromTable(
63
63
  * This function is variadic, meaning that you can specify N arguments to get N values.
64
64
  */
65
65
  export function getNumbersFromTable(
66
- luaTable: LuaTable<string, unknown>,
66
+ luaMap: LuaMap<string, unknown>,
67
67
  objectName: string,
68
68
  ...keys: string[]
69
69
  ): number[] {
70
70
  const numbers: number[] = [];
71
71
  for (const key of keys) {
72
- const value = luaTable.get(key);
72
+ const value = luaMap.get(key);
73
73
  if (value === undefined) {
74
74
  error(
75
75
  `Failed to find a value for "${key}" in a table representing a "${objectName}" object.`,
@@ -103,13 +103,13 @@ export function getNumbersFromTable(
103
103
  * This function is variadic, meaning that you can specify N arguments to get N values.
104
104
  */
105
105
  export function getStringsFromTable(
106
- luaTable: LuaTable<string, unknown>,
106
+ luaMap: LuaMap<string, unknown>,
107
107
  objectName: string,
108
108
  ...keys: string[]
109
109
  ): string[] {
110
110
  const strings: string[] = [];
111
111
  for (const key of keys) {
112
- const value = luaTable.get(key);
112
+ const value = luaMap.get(key);
113
113
  if (value === undefined) {
114
114
  error(
115
115
  `Failed to find a value for "${key}" in a table representing a "${objectName}" object.`,
@@ -136,42 +136,44 @@ export function getStringsFromTable(
136
136
  * This function will only work on tables that have number keys or string keys. It will throw a
137
137
  * run-time error if it encounters a key of another type.
138
138
  *
139
- * @param luaTable The table to iterate over.
139
+ * @param luaMap The table to iterate over.
140
140
  * @param func The function to run for each iteration.
141
141
  * @param inOrder Optional. Whether to iterate in order. True by default. You can dynamically set to
142
142
  * false in situations where iterating randomly would not matter and you need the
143
143
  * extra performance.
144
144
  */
145
145
  export function iterateTableInOrder<K, V>(
146
- luaTable: LuaTable<K, V>,
146
+ luaMap: LuaMap<K, V>,
147
147
  func: (key: K, value: V) => void,
148
148
  inOrder = true,
149
149
  ): void {
150
150
  // First, handle the trivial case of a non-deterministic iteration.
151
151
  if (!inOrder) {
152
- for (const [key, value] of pairs(luaTable)) {
152
+ for (const [key, value] of luaMap) {
153
153
  func(key, value);
154
154
  }
155
155
  return;
156
156
  }
157
157
 
158
- const keys = Object.keys(luaTable);
158
+ const keys = Object.keys(luaMap);
159
159
  const hasAllNumberKeys = keys.every((key) => isNumber(key));
160
160
  const hasAllStringKeys = keys.every((key) => isString(key));
161
161
  if (!hasAllNumberKeys && !hasAllStringKeys) {
162
162
  // Since the table has non-homogenous keys, we won't be able to sort it. Revert to
163
163
  // non-deterministic iteration in this case.
164
- for (const [key, value] of pairs(luaTable)) {
164
+ for (const [key, value] of luaMap) {
165
165
  func(key, value);
166
166
  }
167
167
  return;
168
168
  }
169
- keys.sort();
170
169
 
170
+ keys.sort();
171
171
  for (const key of keys) {
172
172
  const keyIndex = key as unknown as K;
173
- const value = luaTable.get(keyIndex);
174
- func(keyIndex, value);
173
+ const value = luaMap.get(keyIndex);
174
+ if (value !== undefined) {
175
+ func(keyIndex, value);
176
+ }
175
177
  }
176
178
  }
177
179
 
@@ -182,8 +184,8 @@ export function iterateTableInOrder<K, V>(
182
184
  * for.
183
185
  */
184
186
  export function tableHasKeys(
185
- luaTable: LuaTable<AnyNotNil, unknown>,
187
+ luaMap: LuaMap<AnyNotNil, unknown>,
186
188
  ...keys: string[]
187
189
  ): boolean {
188
- return keys.every((key) => luaTable.has(key));
190
+ return keys.every((key) => luaMap.has(key));
189
191
  }
@@ -146,7 +146,7 @@ export function newTSTLClass(oldClass: TSTLClass): TSTLClass {
146
146
 
147
147
  /** This is a re-implementation of the transpiled "__TS__New" function. */
148
148
  function newTSTLClassFromMetatable(metatable: TSTLClassMetatable): TSTLClass {
149
- const newClass = new LuaTable<AnyNotNil, unknown>();
149
+ const newClass = new LuaMap<AnyNotNil, unknown>();
150
150
  const newClassMetatable = setmetatable(
151
151
  newClass,
152
152
  metatable.constructor.prototype,
@@ -27,7 +27,9 @@ export function isString(variable: unknown): variable is string {
27
27
  return type(variable) === "string";
28
28
  }
29
29
 
30
- export function isTable(variable: unknown): variable is LuaTable {
30
+ export function isTable(
31
+ variable: unknown,
32
+ ): variable is LuaMap<AnyNotNil, unknown> {
31
33
  return type(variable) === "table";
32
34
  }
33
35
 
@@ -6,7 +6,7 @@ import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
6
6
  import { copyValuesToTable, getNumbersFromTable, tableHasKeys } from "./table";
7
7
  import { isTable } from "./types";
8
8
 
9
- type SerializedVector = LuaTable<string, unknown> & {
9
+ type SerializedVector = LuaMap<string, unknown> & {
10
10
  readonly __serializedVectorBrand: symbol;
11
11
  };
12
12
 
@@ -55,7 +55,7 @@ export function copyVector(
55
55
  );
56
56
  }
57
57
 
58
- const vectorTable = new LuaTable<string, unknown>();
58
+ const vectorTable = new LuaMap<string, unknown>();
59
59
  copyValuesToTable(vector, KEYS, vectorTable);
60
60
  vectorTable.set(SerializationBrand.VECTOR, "");
61
61
  return vectorTable as SerializedVector;
@@ -69,7 +69,7 @@ export function copyVector(
69
69
  }
70
70
 
71
71
  const [x, y] = getNumbersFromTable(
72
- vector as LuaTable<string, unknown>,
72
+ vector as LuaMap<string, unknown>,
73
73
  OBJECT_NAME,
74
74
  ...KEYS,
75
75
  );
@@ -15,7 +15,7 @@
15
15
  * - `Set`
16
16
  * - serializable Isaac API classes (such as `Color`)
17
17
  * - TSTL classes (i.e. classes that you made yourself)
18
- * - sub-objects or a `LuaTable` that contains the above values
18
+ * - sub-objects or a `LuaMap` that contains the above values
19
19
  *
20
20
  * (Unfortunately, it is not possible to create a recursive type definition that matches these
21
21
  * properties. This means that the TypeScript compiler will not be able to validate that you are
@@ -3,6 +3,6 @@ export interface TSTLClassMetatable {
3
3
  __index: unknown;
4
4
  constructor: {
5
5
  name: string;
6
- prototype: LuaMetatable<LuaTable<AnyNotNil, unknown>>;
6
+ prototype: LuaMetatable<LuaMap<AnyNotNil, unknown>>;
7
7
  };
8
8
  }
@@ -1,6 +1,7 @@
1
1
  /**
2
- * PlayerIndex is a specific type of string; see the documentation for the `getPlayerIndex`
3
- * function. Mods can signify that data structures handle `EntityPlayer` by using this type.
2
+ * PlayerIndex is a specific type of number that represents a unique identifier for a player. Mods
3
+ * can signify that data structures handle `EntityPlayer` by using this type. For more information,
4
+ * see the documentation for the `getPlayerIndex` function.
4
5
  *
5
6
  * For example:
6
7
  *
@@ -1,3 +1,3 @@
1
- export type IsaacAPIClass = LuaTable<string, unknown> & {
1
+ export type IsaacAPIClass = LuaMap<string, unknown> & {
2
2
  readonly __isaacAPIClassBrand: symbol;
3
3
  };
@@ -1,3 +1,3 @@
1
- export type SerializedIsaacAPIClass = LuaTable<string, unknown> & {
1
+ export type SerializedIsaacAPIClass = LuaMap<string, unknown> & {
2
2
  readonly __serializedIsaacAPIClassBrand: symbol;
3
3
  };
@@ -1,3 +1,3 @@
1
- export type TSTLClass = LuaTable<AnyNotNil, unknown> & {
1
+ export type TSTLClass = LuaMap<AnyNotNil, unknown> & {
2
2
  readonly __tstlClassBrand: symbol;
3
3
  };
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializationBrand.d.ts","sourceRoot":"","sources":["../../../src/features/saveDataManager/serializationBrand.ts"],"names":[],"mappings":"AASA,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAM1D"}