isaacscript-common 6.9.0 → 6.10.2

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 (119) 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 +73 -37
  42. package/dist/functions/deepCopyTests.d.ts.map +1 -1
  43. package/dist/functions/deepCopyTests.lua +85 -18
  44. package/dist/functions/entities.d.ts +1 -1
  45. package/dist/functions/entities.d.ts.map +1 -1
  46. package/dist/functions/input.d.ts.map +1 -1
  47. package/dist/functions/input.lua +8 -10
  48. package/dist/functions/jsonHelpers.d.ts +1 -1
  49. package/dist/functions/jsonHelpers.d.ts.map +1 -1
  50. package/dist/functions/kColor.d.ts +1 -1
  51. package/dist/functions/kColor.d.ts.map +1 -1
  52. package/dist/functions/log.d.ts +1 -1
  53. package/dist/functions/log.d.ts.map +1 -1
  54. package/dist/functions/log.lua +3 -1
  55. package/dist/functions/mergeTests.d.ts +2 -2
  56. package/dist/functions/mergeTests.lua +2 -6
  57. package/dist/functions/playerIndex.d.ts +1 -1
  58. package/dist/functions/playerIndex.lua +1 -1
  59. package/dist/functions/rng.d.ts +1 -1
  60. package/dist/functions/rng.d.ts.map +1 -1
  61. package/dist/functions/table.d.ts +9 -9
  62. package/dist/functions/table.d.ts.map +1 -1
  63. package/dist/functions/table.lua +23 -21
  64. package/dist/functions/types.d.ts +1 -1
  65. package/dist/functions/types.d.ts.map +1 -1
  66. package/dist/functions/vector.d.ts +1 -1
  67. package/dist/functions/vector.d.ts.map +1 -1
  68. package/dist/interfaces/SaveData.d.ts +1 -1
  69. package/dist/interfaces/private/TSTLClassMetatable.d.ts +1 -1
  70. package/dist/interfaces/private/TSTLClassMetatable.d.ts.map +1 -1
  71. package/dist/lualib_bundle.lua +38 -7
  72. package/dist/types/PlayerIndex.d.ts +3 -2
  73. package/dist/types/PlayerIndex.d.ts.map +1 -1
  74. package/dist/types/private/IsaacAPIClass.d.ts +1 -1
  75. package/dist/types/private/IsaacAPIClass.d.ts.map +1 -1
  76. package/dist/types/private/SerializedIsaacAPIClass.d.ts +1 -1
  77. package/dist/types/private/SerializedIsaacAPIClass.d.ts.map +1 -1
  78. package/dist/types/private/TSTLClass.d.ts +1 -1
  79. package/dist/types/private/TSTLClass.d.ts.map +1 -1
  80. package/package.json +2 -2
  81. package/src/features/customStage/customStageGridEntities.ts +4 -4
  82. package/src/features/customStage/exports.ts +5 -3
  83. package/src/features/customStage/init.ts +19 -7
  84. package/src/features/customStage/streakText.ts +284 -19
  85. package/src/features/customStage/v.ts +6 -1
  86. package/src/features/customStage/versusScreen.ts +2 -5
  87. package/src/features/extraConsoleCommands/init.ts +1 -0
  88. package/src/features/extraConsoleCommands/listCommands.ts +14 -0
  89. package/src/features/saveDataManager/exports.ts +3 -8
  90. package/src/features/saveDataManager/load.ts +2 -3
  91. package/src/features/saveDataManager/main.ts +4 -5
  92. package/src/features/saveDataManager/maps.ts +3 -3
  93. package/src/features/saveDataManager/merge.ts +11 -11
  94. package/src/features/saveDataManager/save.ts +6 -6
  95. package/src/features/saveDataManager/{serializationBrand.ts → serializationBrands.ts} +0 -0
  96. package/src/functions/array.ts +2 -4
  97. package/src/functions/color.ts +3 -3
  98. package/src/functions/deepCopy.ts +95 -41
  99. package/src/functions/deepCopyTests.ts +161 -28
  100. package/src/functions/entities.ts +7 -7
  101. package/src/functions/input.ts +7 -8
  102. package/src/functions/isaacAPIClass.ts +3 -3
  103. package/src/functions/jsonHelpers.ts +3 -3
  104. package/src/functions/kColor.ts +3 -3
  105. package/src/functions/log.ts +7 -4
  106. package/src/functions/mergeTests.ts +24 -32
  107. package/src/functions/playerIndex.ts +1 -1
  108. package/src/functions/rng.ts +3 -3
  109. package/src/functions/table.ts +25 -23
  110. package/src/functions/tstlClass.ts +1 -1
  111. package/src/functions/types.ts +3 -1
  112. package/src/functions/vector.ts +3 -3
  113. package/src/interfaces/SaveData.ts +1 -1
  114. package/src/interfaces/private/TSTLClassMetatable.ts +1 -1
  115. package/src/types/PlayerIndex.ts +3 -2
  116. package/src/types/private/IsaacAPIClass.ts +1 -1
  117. package/src/types/private/SerializedIsaacAPIClass.ts +1 -1
  118. package/src/types/private/TSTLClass.ts +1 -1
  119. package/dist/features/saveDataManager/serializationBrand.d.ts.map +0 -1
@@ -32,6 +32,12 @@ export function runDeepCopyTests(): void {
32
32
  copiedDefaultMapHasChildDefaultMap();
33
33
  copiedDefaultMapHasBrand();
34
34
 
35
+ copiedSerializedMapHasStringKeyType();
36
+ copiedSerializedMapHasNumberKeyType();
37
+
38
+ copiedSerializedDefaultMapHasStringKeyType();
39
+ copiedSerializedDefaultMapHasNumberKeyType();
40
+
35
41
  log("All deep copy tests passed!");
36
42
  }
37
43
 
@@ -40,7 +46,7 @@ function copiedObjectIsTable() {
40
46
  abc: "def",
41
47
  };
42
48
  const newObject = deepCopy(
43
- oldObject as unknown as LuaTable,
49
+ oldObject as unknown as LuaMap,
44
50
  SerializationType.NONE,
45
51
  "copiedObjectIsTable",
46
52
  );
@@ -56,7 +62,7 @@ function copiedObjectHasKeyAndValueString() {
56
62
  abc: valueToLookFor,
57
63
  };
58
64
  const newTable = deepCopy(
59
- oldObject as unknown as LuaTable,
65
+ oldObject as unknown as LuaMap,
60
66
  SerializationType.NONE,
61
67
  "copiedObjectHasKeyAndValueString",
62
68
  );
@@ -79,7 +85,7 @@ function copiedObjectHasKeyAndValueString() {
79
85
  function copiedTableHasKeyAndValueNumber() {
80
86
  const keyToLookFor = 123;
81
87
  const valueToLookFor = 456;
82
- const oldTable = new LuaTable<AnyNotNil, unknown>();
88
+ const oldTable = new LuaMap<AnyNotNil, unknown>();
83
89
  oldTable.set(keyToLookFor, valueToLookFor);
84
90
 
85
91
  const newObject = deepCopy(
@@ -87,7 +93,7 @@ function copiedTableHasKeyAndValueNumber() {
87
93
  SerializationType.NONE,
88
94
  "copiedTableHasKeyAndValueNumber",
89
95
  );
90
- const newTable = newObject as LuaTable<AnyNotNil, unknown>;
96
+ const newTable = newObject as LuaMap<AnyNotNil, unknown>;
91
97
 
92
98
  const value = newTable.get(keyToLookFor) as number | undefined;
93
99
  if (value === undefined) {
@@ -105,7 +111,7 @@ function copiedTableHasKeyAndValueNumber() {
105
111
  function copiedTableDoesNotCoerceTypes() {
106
112
  const keyToLookFor = 123;
107
113
  const valueToLookFor = 456;
108
- const oldTable = new LuaTable<AnyNotNil, unknown>();
114
+ const oldTable = new LuaMap<AnyNotNil, unknown>();
109
115
  oldTable.set(keyToLookFor, valueToLookFor);
110
116
 
111
117
  const newObject = deepCopy(
@@ -113,7 +119,7 @@ function copiedTableDoesNotCoerceTypes() {
113
119
  SerializationType.NONE,
114
120
  "copiedTableDoesNotCoerceTypes",
115
121
  );
116
- const newTable = newObject as LuaTable<AnyNotNil, unknown>;
122
+ const newTable = newObject as LuaMap<AnyNotNil, unknown>;
117
123
 
118
124
  const keyString = tostring(keyToLookFor);
119
125
  const valueString = tostring(valueToLookFor);
@@ -140,7 +146,7 @@ function copiedObjectHasNoReferencesForPrimitivesForward() {
140
146
  def: originalNumberValue,
141
147
  };
142
148
  const newTable = deepCopy(
143
- oldObject as unknown as LuaTable,
149
+ oldObject as unknown as LuaMap,
144
150
  SerializationType.NONE,
145
151
  "copiedObjectHasNoReferencesForPrimitivesForward",
146
152
  );
@@ -165,7 +171,7 @@ function copiedObjectHasNoReferencesForPrimitivesBackward() {
165
171
  def: originalNumberValue,
166
172
  };
167
173
  const newTable = deepCopy(
168
- oldObject as unknown as LuaTable,
174
+ oldObject as unknown as LuaMap,
169
175
  SerializationType.NONE,
170
176
  "copiedObjectHasNoReferencesForPrimitivesBackward",
171
177
  );
@@ -188,7 +194,7 @@ function copiedObjectHasNoReferencesForArray() {
188
194
  abc: [1, 2, 3],
189
195
  };
190
196
  const newTable = deepCopy(
191
- oldObject as unknown as LuaTable,
197
+ oldObject as unknown as LuaMap,
192
198
  SerializationType.NONE,
193
199
  "copiedObjectHasNoReferencesForArray",
194
200
  );
@@ -229,7 +235,7 @@ function copiedObjectHasChildObject() {
229
235
  },
230
236
  };
231
237
  const newTable = deepCopy(
232
- oldObject as unknown as LuaTable,
238
+ oldObject as unknown as LuaMap,
233
239
  SerializationType.NONE,
234
240
  "copiedObjectHasChildObject",
235
241
  );
@@ -268,11 +274,8 @@ function copiedMapIsMap() {
268
274
  const newObject = deepCopy(oldMap, SerializationType.NONE, "copiedMapIsMap");
269
275
  const newMap = newObject as Map<string, string>;
270
276
 
271
- if (!isTable(newMap)) {
272
- error(`The copied Map had a type of: ${typeof newMap}`);
273
- }
274
277
  if (!isTSTLMap(newMap)) {
275
- error("The copied Map was not a Map.");
278
+ error(`The copied Map was not a Map and has a type of: ${typeof newMap}`);
276
279
  }
277
280
  }
278
281
 
@@ -287,8 +290,13 @@ function copiedMapHasValue() {
287
290
  SerializationType.NONE,
288
291
  "copiedMapHasValue",
289
292
  );
293
+
290
294
  const newMap = newTable as typeof oldMap;
291
295
 
296
+ if (!isTSTLMap(newMap)) {
297
+ error(`The copied Map was not a Map and has a type of: ${typeof newMap}`);
298
+ }
299
+
292
300
  const value = newMap.get(keyToLookFor);
293
301
  if (value === undefined) {
294
302
  error(`The copied Map did not have a key of: ${keyToLookFor}`);
@@ -306,11 +314,8 @@ function copiedSetIsSet() {
306
314
  const newTable = deepCopy(oldSet, SerializationType.NONE, "copiedSetIsSet");
307
315
  const newSet = newTable as Set<string>;
308
316
 
309
- if (!isTable(newSet)) {
310
- error(`The copied Set had a type of: ${typeof newSet}`);
311
- }
312
317
  if (!isTSTLSet(newSet)) {
313
- error("The copied Set was not a Map.");
318
+ error(`The copied Set was not a Set and has a type of: ${typeof newSet}`);
314
319
  }
315
320
  }
316
321
 
@@ -326,6 +331,10 @@ function copiedSetHasValue() {
326
331
  );
327
332
  const newSet = newTable as Set<string>;
328
333
 
334
+ if (!isTSTLSet(newSet)) {
335
+ error(`The copied Set was not a Set and has a type of: ${typeof newSet}`);
336
+ }
337
+
329
338
  const hasValue = newSet.has(valueToLookFor);
330
339
  if (!hasValue) {
331
340
  error(`The copied Set did not have a value of: ${valueToLookFor}`);
@@ -338,7 +347,7 @@ function copiedMapHasChildMap() {
338
347
  const oldChildMap = new Map<number, number>();
339
348
  oldChildMap.set(childMapKey, childMapValue);
340
349
 
341
- const keyToLookFor = "abc";
350
+ const keyToLookFor = "childMap";
342
351
  const oldMap = new Map<string, Map<number, number>>();
343
352
  oldMap.set(keyToLookFor, oldChildMap);
344
353
 
@@ -349,16 +358,19 @@ function copiedMapHasChildMap() {
349
358
  );
350
359
  const newMap = newTable as typeof oldMap;
351
360
 
361
+ if (!isTSTLMap(newMap)) {
362
+ error(`The copied Map was not a Map and had a type of: ${typeof newMap}`);
363
+ }
364
+
352
365
  const newChildMap = newMap.get(keyToLookFor);
353
366
  if (newChildMap === undefined) {
354
367
  error(`The copied Map did not have a child map at key: ${keyToLookFor}`);
355
368
  }
356
369
 
357
- if (!isTable(newChildMap)) {
358
- error(`The copied child Map had a type of: ${typeof newChildMap}`);
359
- }
360
370
  if (!isTSTLMap(newChildMap)) {
361
- error("The copied child Map was not a Map.");
371
+ error(
372
+ `The copied child Map was not a Map and had a type of: ${typeof newChildMap}`,
373
+ );
362
374
  }
363
375
 
364
376
  const value = newChildMap.get(childMapKey);
@@ -390,6 +402,12 @@ function copiedDefaultMapHasChildDefaultMap() {
390
402
  );
391
403
  const newParentMap = newTable as typeof oldParentMap;
392
404
 
405
+ if (!isDefaultMap(newParentMap)) {
406
+ error(
407
+ `The copied parent DefaultMap was not a DefaultMap and had a type of: ${typeof newParentMap}`,
408
+ );
409
+ }
410
+
393
411
  const newChildMap = newParentMap.get(parentMapKey);
394
412
  if (newChildMap === undefined) {
395
413
  error(
@@ -397,11 +415,10 @@ function copiedDefaultMapHasChildDefaultMap() {
397
415
  );
398
416
  }
399
417
 
400
- if (!isTable(newChildMap)) {
401
- error(`The copied child DefaultMap had a type of: ${typeof newChildMap}`);
402
- }
403
418
  if (!isDefaultMap(newChildMap)) {
404
- error("The copied child DefaultMap was not a DefaultMap.");
419
+ error(
420
+ `The copied child DefaultMap was not a DefaultMap and had a type of: ${typeof newChildMap}`,
421
+ );
405
422
  }
406
423
 
407
424
  const newChildMapValue1 = newChildMap.get(childMapKey1);
@@ -432,7 +449,13 @@ function copiedDefaultMapHasBrand() {
432
449
  oldDefaultMap,
433
450
  SerializationType.SERIALIZE,
434
451
  "copiedDefaultMapHasBrand",
435
- ) as LuaTable<AnyNotNil, unknown>;
452
+ ) as LuaMap<AnyNotNil, unknown>;
453
+
454
+ if (!isTable(newTable)) {
455
+ error(
456
+ `The copied DefaultMap was not a table and had a type of: ${typeof newTable}`,
457
+ );
458
+ }
436
459
 
437
460
  if (!newTable.has(SerializationBrand.DEFAULT_MAP)) {
438
461
  error(
@@ -440,3 +463,113 @@ function copiedDefaultMapHasBrand() {
440
463
  );
441
464
  }
442
465
  }
466
+
467
+ function copiedSerializedMapHasStringKeyType() {
468
+ const mapKey = "123";
469
+ const mapValue = 456;
470
+ const oldMap = new Map<string, number>();
471
+ oldMap.set(mapKey, mapValue);
472
+
473
+ const tempTable = deepCopy(
474
+ oldMap,
475
+ SerializationType.SERIALIZE,
476
+ "copiedSerializedMapHasStringKeyTypeSerialize",
477
+ );
478
+
479
+ const newTable = deepCopy(
480
+ tempTable,
481
+ SerializationType.DESERIALIZE,
482
+ "copiedSerializedMapHasStringKeyTypeDeserialize",
483
+ );
484
+
485
+ const newMap = newTable as Map<string, number>;
486
+ if (![...newMap.keys()].includes(mapKey)) {
487
+ error(
488
+ `The copied Map did not have a key of: ${mapKey} with type ${type(
489
+ mapKey,
490
+ )}`,
491
+ );
492
+ }
493
+ }
494
+
495
+ function copiedSerializedMapHasNumberKeyType() {
496
+ const mapKey = 123;
497
+ const mapValue = 456;
498
+ const oldMap = new Map<number, number>();
499
+ oldMap.set(mapKey, mapValue);
500
+
501
+ const tempTable = deepCopy(
502
+ oldMap,
503
+ SerializationType.SERIALIZE,
504
+ "copiedSerializedMapHasNumberKeyTypeSerialize",
505
+ );
506
+
507
+ const newTable = deepCopy(
508
+ tempTable,
509
+ SerializationType.DESERIALIZE,
510
+ "copiedSerializedMapHasNumberKeyTypeDeserialize",
511
+ );
512
+
513
+ const newMap = newTable as Map<number, number>;
514
+ if (![...newMap.keys()].includes(mapKey)) {
515
+ error(
516
+ `The copied Map did not have a key of: ${mapKey} with type ${type(
517
+ mapKey,
518
+ )}`,
519
+ );
520
+ }
521
+ }
522
+
523
+ function copiedSerializedDefaultMapHasStringKeyType() {
524
+ const mapKey = "123";
525
+ const oldMap = new DefaultMap<string, number>(456);
526
+ oldMap.getAndSetDefault(mapKey);
527
+
528
+ const tempTable = deepCopy(
529
+ oldMap,
530
+ SerializationType.SERIALIZE,
531
+ "copiedSerializedDefaultMapHasStringKeyTypeSerialize",
532
+ );
533
+
534
+ const newTable = deepCopy(
535
+ tempTable,
536
+ SerializationType.DESERIALIZE,
537
+ "copiedSerializedDefaultMapHasStringKeyTypeDeserialize",
538
+ );
539
+
540
+ const newMap = newTable as DefaultMap<string, number>;
541
+ if (![...newMap.keys()].includes(mapKey)) {
542
+ error(
543
+ `The copied DefaultMap did not have a key of: ${mapKey} with type ${type(
544
+ mapKey,
545
+ )}`,
546
+ );
547
+ }
548
+ }
549
+
550
+ function copiedSerializedDefaultMapHasNumberKeyType() {
551
+ const mapKey = 123;
552
+ const oldMap = new DefaultMap<number, number>(456);
553
+ oldMap.getAndSetDefault(mapKey);
554
+
555
+ const tempTable = deepCopy(
556
+ oldMap,
557
+ SerializationType.SERIALIZE,
558
+ "copiedSerializedDefaultMapHasNumberKeyTypeSerialize",
559
+ );
560
+
561
+ const newTable = deepCopy(
562
+ tempTable,
563
+ SerializationType.DESERIALIZE,
564
+ "copiedSerializedDefaultMapHasNumberKeyTypeDeserialize",
565
+ );
566
+
567
+ const newMap = newTable as DefaultMap<number, number>;
568
+ if (![...newMap.keys()].includes(mapKey)) {
569
+ error(
570
+ `The copied DefaultMap did not have a key of: ${mapKey} with type ${type(
571
+ mapKey,
572
+ )}`,
573
+ );
574
+ }
575
+ }
@@ -137,11 +137,11 @@ export function getEntities(
137
137
  */
138
138
  export function getEntityFields(
139
139
  entity: Entity,
140
- ): LuaTable<string, boolean | number | string> {
141
- const entityFields = new LuaTable<string, boolean | number | string>();
140
+ ): LuaMap<string, boolean | number | string> {
141
+ const entityFields = new LuaMap<string, boolean | number | string>();
142
142
 
143
143
  const metatable = getmetatable(entity) as
144
- | LuaTable<AnyNotNil, unknown>
144
+ | LuaMap<AnyNotNil, unknown>
145
145
  | undefined;
146
146
  if (metatable === undefined) {
147
147
  error("Failed to get the metatable for an entity.");
@@ -158,7 +158,7 @@ export function getEntityFields(
158
158
  }
159
159
 
160
160
  const parentTable = metatable.get("__parent") as
161
- | LuaTable<AnyNotNil, unknown>
161
+ | LuaMap<AnyNotNil, unknown>
162
162
  | undefined;
163
163
  if (parentTable === undefined) {
164
164
  error('Failed to get the "__parent" table for an entity.');
@@ -171,11 +171,11 @@ export function getEntityFields(
171
171
 
172
172
  function setPrimitiveEntityFields(
173
173
  entity: Entity,
174
- metatable: LuaTable<AnyNotNil, unknown>,
175
- entityFields: LuaTable<string, boolean | number | string>,
174
+ metatable: LuaMap<AnyNotNil, unknown>,
175
+ entityFields: LuaMap<string, boolean | number | string>,
176
176
  ) {
177
177
  const propGetTable = metatable.get("__propget") as
178
- | LuaTable<AnyNotNil, unknown>
178
+ | LuaMap<AnyNotNil, unknown>
179
179
  | undefined;
180
180
  if (propGetTable === undefined) {
181
181
  error('Failed to get the "__propget" table for an entity.');
@@ -4,10 +4,9 @@ import {
4
4
  ControllerIndex,
5
5
  Keyboard,
6
6
  } from "isaac-typescript-definitions";
7
- import { MAX_NUM_INPUTS } from "../constants";
7
+ import { getEnumValues } from "./enums";
8
8
  import { copySet } from "./set";
9
9
  import { trimPrefix } from "./string";
10
- import { erange } from "./utils";
11
10
 
12
11
  const MODIFIER_KEYS: readonly Keyboard[] = [
13
12
  Keyboard.LEFT_SHIFT, // 340
@@ -62,9 +61,9 @@ export function getShootActions(): Set<ButtonAction> {
62
61
 
63
62
  /** Iterates over all inputs to determine if a particular button is pressed (i.e. held down). */
64
63
  export function isActionPressedOnAnyInput(buttonAction: ButtonAction): boolean {
65
- const validInputs = erange(MAX_NUM_INPUTS);
66
- return validInputs.some((input) =>
67
- Input.IsActionPressed(buttonAction, input),
64
+ const controllerIndexes = getEnumValues(ControllerIndex);
65
+ return controllerIndexes.some((controllerIndex) =>
66
+ Input.IsActionPressed(buttonAction, controllerIndex),
68
67
  );
69
68
  }
70
69
 
@@ -75,9 +74,9 @@ export function isActionPressedOnAnyInput(buttonAction: ButtonAction): boolean {
75
74
  export function isActionTriggeredOnAnyInput(
76
75
  buttonAction: ButtonAction,
77
76
  ): boolean {
78
- const validInputs = erange(MAX_NUM_INPUTS);
79
- return validInputs.some((input) =>
80
- Input.IsActionTriggered(buttonAction, input),
77
+ const controllerIndexes = getEnumValues(ControllerIndex);
78
+ return controllerIndexes.some((controllerIndex) =>
79
+ Input.IsActionTriggered(buttonAction, controllerIndex),
81
80
  );
82
81
  }
83
82
 
@@ -16,7 +16,7 @@ export function getIsaacAPIClassName(object: unknown): string | undefined {
16
16
  }
17
17
 
18
18
  const metatable = getmetatable(object) as
19
- | LuaTable<AnyNotNil, unknown>
19
+ | LuaMap<AnyNotNil, unknown>
20
20
  | undefined;
21
21
  if (metatable === undefined) {
22
22
  return undefined;
@@ -60,8 +60,8 @@ export function isaacAPIClassEquals(
60
60
  object2: unknown,
61
61
  keys: string[],
62
62
  ): boolean {
63
- const table1 = object1 as LuaTable<AnyNotNil, unknown>;
64
- const table2 = object2 as LuaTable<AnyNotNil, unknown>;
63
+ const table1 = object1 as LuaMap<AnyNotNil, unknown>;
64
+ const table2 = object2 as LuaMap<AnyNotNil, unknown>;
65
65
 
66
66
  return keys.every((key) => table1.get(key) === table2.get(key));
67
67
  }
@@ -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]");