isaacscript-common 6.9.0 → 6.10.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 (118) 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 +27 -27
  42. package/dist/functions/deepCopyTests.lua +3 -3
  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/table.d.ts +9 -9
  61. package/dist/functions/table.d.ts.map +1 -1
  62. package/dist/functions/table.lua +23 -21
  63. package/dist/functions/types.d.ts +1 -1
  64. package/dist/functions/types.d.ts.map +1 -1
  65. package/dist/functions/vector.d.ts +1 -1
  66. package/dist/functions/vector.d.ts.map +1 -1
  67. package/dist/interfaces/SaveData.d.ts +1 -1
  68. package/dist/interfaces/private/TSTLClassMetatable.d.ts +1 -1
  69. package/dist/interfaces/private/TSTLClassMetatable.d.ts.map +1 -1
  70. package/dist/lualib_bundle.lua +38 -7
  71. package/dist/types/PlayerIndex.d.ts +3 -2
  72. package/dist/types/PlayerIndex.d.ts.map +1 -1
  73. package/dist/types/private/IsaacAPIClass.d.ts +1 -1
  74. package/dist/types/private/IsaacAPIClass.d.ts.map +1 -1
  75. package/dist/types/private/SerializedIsaacAPIClass.d.ts +1 -1
  76. package/dist/types/private/SerializedIsaacAPIClass.d.ts.map +1 -1
  77. package/dist/types/private/TSTLClass.d.ts +1 -1
  78. package/dist/types/private/TSTLClass.d.ts.map +1 -1
  79. package/package.json +2 -2
  80. package/src/features/customStage/customStageGridEntities.ts +4 -4
  81. package/src/features/customStage/exports.ts +5 -3
  82. package/src/features/customStage/init.ts +19 -7
  83. package/src/features/customStage/streakText.ts +284 -19
  84. package/src/features/customStage/v.ts +6 -1
  85. package/src/features/customStage/versusScreen.ts +2 -5
  86. package/src/features/extraConsoleCommands/init.ts +1 -0
  87. package/src/features/extraConsoleCommands/listCommands.ts +14 -0
  88. package/src/features/saveDataManager/exports.ts +3 -8
  89. package/src/features/saveDataManager/load.ts +2 -3
  90. package/src/features/saveDataManager/main.ts +4 -5
  91. package/src/features/saveDataManager/maps.ts +3 -3
  92. package/src/features/saveDataManager/merge.ts +11 -11
  93. package/src/features/saveDataManager/save.ts +6 -6
  94. package/src/features/saveDataManager/{serializationBrand.ts → serializationBrands.ts} +0 -0
  95. package/src/functions/array.ts +2 -4
  96. package/src/functions/color.ts +3 -3
  97. package/src/functions/deepCopy.ts +39 -36
  98. package/src/functions/deepCopyTests.ts +11 -11
  99. package/src/functions/entities.ts +7 -7
  100. package/src/functions/input.ts +7 -8
  101. package/src/functions/isaacAPIClass.ts +3 -3
  102. package/src/functions/jsonHelpers.ts +3 -3
  103. package/src/functions/kColor.ts +3 -3
  104. package/src/functions/log.ts +5 -4
  105. package/src/functions/mergeTests.ts +24 -24
  106. package/src/functions/playerIndex.ts +1 -1
  107. package/src/functions/rng.ts +3 -3
  108. package/src/functions/table.ts +25 -23
  109. package/src/functions/tstlClass.ts +1 -1
  110. package/src/functions/types.ts +3 -1
  111. package/src/functions/vector.ts +3 -3
  112. package/src/interfaces/SaveData.ts +1 -1
  113. package/src/interfaces/private/TSTLClassMetatable.ts +1 -1
  114. package/src/types/PlayerIndex.ts +3 -2
  115. package/src/types/private/IsaacAPIClass.ts +1 -1
  116. package/src/types/private/SerializedIsaacAPIClass.ts +1 -1
  117. package/src/types/private/TSTLClass.ts +1 -1
  118. package/dist/features/saveDataManager/serializationBrand.d.ts.map +0 -1
@@ -3,7 +3,7 @@ import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClas
3
3
  import { SerializationBrand } from "../enums/private/SerializationBrand";
4
4
  import { SerializationType } from "../enums/SerializationType";
5
5
  import { SAVE_DATA_MANAGER_DEBUG } from "../features/saveDataManager/saveDataManagerConstants";
6
- import { isSerializationBrand } from "../features/saveDataManager/serializationBrand";
6
+ import { isSerializationBrand } from "../features/saveDataManager/serializationBrands";
7
7
  import { TSTLClass } from "../types/private/TSTLClass";
8
8
  import { isArray } from "./array";
9
9
  import { getEnumValues } from "./enums";
@@ -36,7 +36,7 @@ const COPYABLE_ISAAC_API_CLASS_TYPES_SET = new Set<string>(
36
36
  * It supports the following object types:
37
37
  *
38
38
  * - Primitives (i.e. strings, numbers, and booleans)
39
- * - `LuaTable` / basic TSTL objects
39
+ * - Basic TSTL objects / tables
40
40
  * - TSTL `Map`
41
41
  * - TSTL `Set`
42
42
  * - TSTL classes
@@ -101,9 +101,9 @@ export function deepCopy(
101
101
  }
102
102
 
103
103
  case "table": {
104
- const luaTable = value as LuaTable<AnyNotNil, unknown>;
104
+ const luaMap = value as LuaMap<AnyNotNil, unknown>;
105
105
  return deepCopyTable(
106
- luaTable,
106
+ luaMap,
107
107
  serializationType,
108
108
  traversalDescription,
109
109
  insideMap,
@@ -117,40 +117,40 @@ export function deepCopy(
117
117
  }
118
118
 
119
119
  function deepCopyTable(
120
- luaTable: LuaTable<AnyNotNil, unknown>,
120
+ luaMap: LuaMap<AnyNotNil, unknown>,
121
121
  serializationType: SerializationType,
122
122
  traversalDescription: string,
123
123
  insideMap: boolean,
124
124
  ) {
125
125
  // First, handle the cases of TSTL classes or serialized TSTL classes.
126
- if (isDefaultMap(luaTable) || luaTable.has(SerializationBrand.DEFAULT_MAP)) {
126
+ if (isDefaultMap(luaMap) || luaMap.has(SerializationBrand.DEFAULT_MAP)) {
127
127
  return deepCopyDefaultMap(
128
- luaTable,
128
+ luaMap,
129
129
  serializationType,
130
130
  traversalDescription,
131
131
  insideMap,
132
132
  );
133
133
  }
134
134
 
135
- if (isTSTLMap(luaTable) || luaTable.has(SerializationBrand.MAP)) {
135
+ if (isTSTLMap(luaMap) || luaMap.has(SerializationBrand.MAP)) {
136
136
  return deepCopyMap(
137
- luaTable,
137
+ luaMap,
138
138
  serializationType,
139
139
  traversalDescription,
140
140
  insideMap,
141
141
  );
142
142
  }
143
143
 
144
- if (isTSTLSet(luaTable) || luaTable.has(SerializationBrand.SET)) {
144
+ if (isTSTLSet(luaMap) || luaMap.has(SerializationBrand.SET)) {
145
145
  return deepCopySet(
146
- luaTable,
146
+ luaMap,
147
147
  serializationType,
148
148
  traversalDescription,
149
149
  insideMap,
150
150
  );
151
151
  }
152
152
 
153
- const className = getTSTLClassName(luaTable);
153
+ const className = getTSTLClassName(luaMap);
154
154
 
155
155
  if (className === "WeakMap") {
156
156
  error(
@@ -164,9 +164,9 @@ function deepCopyTable(
164
164
  );
165
165
  }
166
166
 
167
- if (isUserDefinedTSTLClass(luaTable)) {
167
+ if (isUserDefinedTSTLClass(luaMap)) {
168
168
  return deepCopyTSTLClass(
169
- luaTable,
169
+ luaMap,
170
170
  serializationType,
171
171
  traversalDescription,
172
172
  insideMap,
@@ -174,20 +174,20 @@ function deepCopyTable(
174
174
  }
175
175
 
176
176
  // This is not a TSTL Map/Set/class. If it has a metatable, abort.
177
- checkMetatable(luaTable, traversalDescription);
177
+ checkMetatable(luaMap, traversalDescription);
178
178
 
179
179
  // Handle the special case of serialized Isaac API classes.
180
180
  if (
181
- isSerializedIsaacAPIClass(luaTable) &&
181
+ isSerializedIsaacAPIClass(luaMap) &&
182
182
  serializationType === SerializationType.DESERIALIZE
183
183
  ) {
184
- return deserializeIsaacAPIClass(luaTable);
184
+ return deserializeIsaacAPIClass(luaMap);
185
185
  }
186
186
 
187
187
  // Handle the special case of an array.
188
- if (isArray(luaTable)) {
188
+ if (isArray(luaMap)) {
189
189
  return deepCopyArray(
190
- luaTable,
190
+ luaMap,
191
191
  serializationType,
192
192
  traversalDescription,
193
193
  insideMap,
@@ -196,7 +196,7 @@ function deepCopyTable(
196
196
 
197
197
  // Base case: copy a normal Lua table
198
198
  return deepCopyNormalLuaTable(
199
- luaTable,
199
+ luaMap,
200
200
  serializationType,
201
201
  traversalDescription,
202
202
  insideMap,
@@ -204,7 +204,7 @@ function deepCopyTable(
204
204
  }
205
205
 
206
206
  function deepCopyDefaultMap(
207
- defaultMap: DefaultMap<AnyNotNil, unknown> | LuaTable<AnyNotNil, unknown>,
207
+ defaultMap: DefaultMap<AnyNotNil, unknown> | LuaMap<AnyNotNil, unknown>,
208
208
  serializationType: SerializationType,
209
209
  traversalDescription: string,
210
210
  insideMap: boolean,
@@ -287,7 +287,7 @@ function deepCopyDefaultMap(
287
287
  * whether we are serializing or not.
288
288
  */
289
289
  function getNewDefaultMap(
290
- defaultMap: DefaultMap<AnyNotNil, unknown> | LuaTable<AnyNotNil, unknown>,
290
+ defaultMap: DefaultMap<AnyNotNil, unknown> | LuaMap<AnyNotNil, unknown>,
291
291
  serializationType: SerializationType,
292
292
  traversalDescription: string,
293
293
  constructorArg: unknown,
@@ -301,7 +301,7 @@ function getNewDefaultMap(
301
301
  case SerializationType.SERIALIZE: {
302
302
  // Since we are serializing, the new object will be a Lua table. (At this point, we already
303
303
  // handled the special case of a DefaultMap instantiated with a factory function.)
304
- const newDefaultMap = new LuaTable<AnyNotNil, unknown>();
304
+ const newDefaultMap = new LuaMap<AnyNotNil, unknown>();
305
305
  newDefaultMap.set(SerializationBrand.DEFAULT_MAP, "");
306
306
  newDefaultMap.set(SerializationBrand.DEFAULT_MAP_VALUE, constructorArg);
307
307
 
@@ -331,15 +331,15 @@ function getNewDefaultMap(
331
331
  }
332
332
 
333
333
  function deepCopyMap(
334
- map: Map<AnyNotNil, unknown> | LuaTable<AnyNotNil, unknown>,
334
+ map: Map<AnyNotNil, unknown> | LuaMap<AnyNotNil, unknown>,
335
335
  serializationType: SerializationType,
336
336
  traversalDescription: string,
337
337
  insideMap: boolean,
338
338
  ) {
339
- let newMap: Map<AnyNotNil, unknown> | LuaTable<AnyNotNil, unknown>;
339
+ let newMap: Map<AnyNotNil, unknown> | LuaMap<AnyNotNil, unknown>;
340
340
  if (serializationType === SerializationType.SERIALIZE) {
341
341
  // Since we are serializing, the new object will be a Lua table.
342
- newMap = new LuaTable<AnyNotNil, unknown>();
342
+ newMap = new LuaMap<AnyNotNil, unknown>();
343
343
  newMap.set(SerializationBrand.MAP, "");
344
344
  } else {
345
345
  newMap = new Map();
@@ -379,16 +379,16 @@ function deepCopyMap(
379
379
  }
380
380
 
381
381
  function deepCopySet(
382
- set: Set<AnyNotNil> | LuaTable<AnyNotNil, unknown>,
382
+ set: Set<AnyNotNil> | LuaMap<AnyNotNil, unknown>,
383
383
  serializationType: SerializationType,
384
384
  traversalDescription: string,
385
385
  insideMap: boolean,
386
386
  ) {
387
- let newSet: Set<AnyNotNil> | LuaTable<AnyNotNil, string>;
387
+ let newSet: Set<AnyNotNil> | LuaMap<AnyNotNil, string>;
388
388
  if (serializationType === SerializationType.SERIALIZE) {
389
389
  // For serialization purposes, we represent a `Set` as a table with keys that match the
390
390
  // keys/values in the Set and values of an empty string.
391
- newSet = new LuaTable<AnyNotNil, string>();
391
+ newSet = new LuaMap<AnyNotNil, string>();
392
392
  newSet.set(SerializationBrand.SET, "");
393
393
  } else {
394
394
  newSet = new Set();
@@ -433,10 +433,10 @@ function deepCopyTSTLClass(
433
433
  traversalDescription: string,
434
434
  insideMap: boolean,
435
435
  ) {
436
- let newClass: TSTLClass | LuaTable<AnyNotNil, unknown>;
436
+ let newClass: TSTLClass | LuaMap<AnyNotNil, unknown>;
437
437
  if (serializationType === SerializationType.SERIALIZE) {
438
438
  // Since we are serializing, the new object will be a Lua table.
439
- newClass = new LuaTable<AnyNotNil, unknown>();
439
+ newClass = new LuaMap<AnyNotNil, unknown>();
440
440
  // (We do not brand it with the class type because we will not have the associated class
441
441
  // constructor during deserialization, so knowing what type of class it is is pointless.)
442
442
  } else {
@@ -483,14 +483,14 @@ function deepCopyArray(
483
483
  }
484
484
 
485
485
  function deepCopyNormalLuaTable(
486
- luaTable: LuaTable<AnyNotNil, unknown>,
486
+ luaMap: LuaMap<AnyNotNil, unknown>,
487
487
  serializationType: SerializationType,
488
488
  traversalDescription: string,
489
489
  insideMap: boolean,
490
490
  ) {
491
- const newTable = new LuaTable<AnyNotNil, unknown>();
491
+ const newTable = new LuaMap<AnyNotNil, unknown>();
492
492
  const { entries, convertedNumberKeysToStrings } = getCopiedEntries(
493
- luaTable,
493
+ luaMap,
494
494
  serializationType,
495
495
  traversalDescription,
496
496
  insideMap,
@@ -575,8 +575,11 @@ function getCopiedEntries(
575
575
  * copy function will refuse to copy a table type that has a metatable, outside of specifically
576
576
  * supported TSTL objects.
577
577
  */
578
- function checkMetatable(luaTable: LuaTable, traversalDescription: string) {
579
- const metatable = getmetatable(luaTable);
578
+ function checkMetatable(
579
+ luaMap: LuaMap<AnyNotNil, unknown>,
580
+ traversalDescription: string,
581
+ ) {
582
+ const metatable = getmetatable(luaMap);
580
583
  if (metatable === undefined) {
581
584
  return;
582
585
  }
@@ -40,7 +40,7 @@ function copiedObjectIsTable() {
40
40
  abc: "def",
41
41
  };
42
42
  const newObject = deepCopy(
43
- oldObject as unknown as LuaTable,
43
+ oldObject as unknown as LuaMap,
44
44
  SerializationType.NONE,
45
45
  "copiedObjectIsTable",
46
46
  );
@@ -56,7 +56,7 @@ function copiedObjectHasKeyAndValueString() {
56
56
  abc: valueToLookFor,
57
57
  };
58
58
  const newTable = deepCopy(
59
- oldObject as unknown as LuaTable,
59
+ oldObject as unknown as LuaMap,
60
60
  SerializationType.NONE,
61
61
  "copiedObjectHasKeyAndValueString",
62
62
  );
@@ -79,7 +79,7 @@ function copiedObjectHasKeyAndValueString() {
79
79
  function copiedTableHasKeyAndValueNumber() {
80
80
  const keyToLookFor = 123;
81
81
  const valueToLookFor = 456;
82
- const oldTable = new LuaTable<AnyNotNil, unknown>();
82
+ const oldTable = new LuaMap<AnyNotNil, unknown>();
83
83
  oldTable.set(keyToLookFor, valueToLookFor);
84
84
 
85
85
  const newObject = deepCopy(
@@ -87,7 +87,7 @@ function copiedTableHasKeyAndValueNumber() {
87
87
  SerializationType.NONE,
88
88
  "copiedTableHasKeyAndValueNumber",
89
89
  );
90
- const newTable = newObject as LuaTable<AnyNotNil, unknown>;
90
+ const newTable = newObject as LuaMap<AnyNotNil, unknown>;
91
91
 
92
92
  const value = newTable.get(keyToLookFor) as number | undefined;
93
93
  if (value === undefined) {
@@ -105,7 +105,7 @@ function copiedTableHasKeyAndValueNumber() {
105
105
  function copiedTableDoesNotCoerceTypes() {
106
106
  const keyToLookFor = 123;
107
107
  const valueToLookFor = 456;
108
- const oldTable = new LuaTable<AnyNotNil, unknown>();
108
+ const oldTable = new LuaMap<AnyNotNil, unknown>();
109
109
  oldTable.set(keyToLookFor, valueToLookFor);
110
110
 
111
111
  const newObject = deepCopy(
@@ -113,7 +113,7 @@ function copiedTableDoesNotCoerceTypes() {
113
113
  SerializationType.NONE,
114
114
  "copiedTableDoesNotCoerceTypes",
115
115
  );
116
- const newTable = newObject as LuaTable<AnyNotNil, unknown>;
116
+ const newTable = newObject as LuaMap<AnyNotNil, unknown>;
117
117
 
118
118
  const keyString = tostring(keyToLookFor);
119
119
  const valueString = tostring(valueToLookFor);
@@ -140,7 +140,7 @@ function copiedObjectHasNoReferencesForPrimitivesForward() {
140
140
  def: originalNumberValue,
141
141
  };
142
142
  const newTable = deepCopy(
143
- oldObject as unknown as LuaTable,
143
+ oldObject as unknown as LuaMap,
144
144
  SerializationType.NONE,
145
145
  "copiedObjectHasNoReferencesForPrimitivesForward",
146
146
  );
@@ -165,7 +165,7 @@ function copiedObjectHasNoReferencesForPrimitivesBackward() {
165
165
  def: originalNumberValue,
166
166
  };
167
167
  const newTable = deepCopy(
168
- oldObject as unknown as LuaTable,
168
+ oldObject as unknown as LuaMap,
169
169
  SerializationType.NONE,
170
170
  "copiedObjectHasNoReferencesForPrimitivesBackward",
171
171
  );
@@ -188,7 +188,7 @@ function copiedObjectHasNoReferencesForArray() {
188
188
  abc: [1, 2, 3],
189
189
  };
190
190
  const newTable = deepCopy(
191
- oldObject as unknown as LuaTable,
191
+ oldObject as unknown as LuaMap,
192
192
  SerializationType.NONE,
193
193
  "copiedObjectHasNoReferencesForArray",
194
194
  );
@@ -229,7 +229,7 @@ function copiedObjectHasChildObject() {
229
229
  },
230
230
  };
231
231
  const newTable = deepCopy(
232
- oldObject as unknown as LuaTable,
232
+ oldObject as unknown as LuaMap,
233
233
  SerializationType.NONE,
234
234
  "copiedObjectHasChildObject",
235
235
  );
@@ -432,7 +432,7 @@ function copiedDefaultMapHasBrand() {
432
432
  oldDefaultMap,
433
433
  SerializationType.SERIALIZE,
434
434
  "copiedDefaultMapHasBrand",
435
- ) as LuaTable<AnyNotNil, unknown>;
435
+ ) as LuaMap<AnyNotNil, unknown>;
436
436
 
437
437
  if (!newTable.has(SerializationBrand.DEFAULT_MAP)) {
438
438
  error(
@@ -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
  );
@@ -658,7 +658,8 @@ export function logTable(
658
658
  // Put it in an IIFE so that the it will show as "func" instead of "logTable" and align with the
659
659
  // other text.
660
660
  (() => {
661
- log(`${indentation}The size of the table was: ${luaTable.length()}`);
661
+ const { length } = Object.keys(luaTable);
662
+ log(`${indentation}The size of the table was: ${length}`);
662
663
  })();
663
664
  }
664
665
 
@@ -668,8 +669,8 @@ export function logTable(
668
669
  */
669
670
  export function logTableDifferences<K, V>(
670
671
  this: void,
671
- table1: LuaTable<K, V>,
672
- table2: LuaTable<K, V>,
672
+ table1: LuaMap<K, V>,
673
+ table2: LuaMap<K, V>,
673
674
  ): void {
674
675
  log("Comparing two Lua tables:");
675
676
 
@@ -725,7 +726,7 @@ export function logUserdata(this: void, userdata: unknown): void {
725
726
  }
726
727
 
727
728
  const metatable = getmetatable(userdata) as
728
- | LuaTable<AnyNotNil, unknown>
729
+ | LuaMap<AnyNotNil, unknown>
729
730
  | undefined;
730
731
  if (metatable === undefined) {
731
732
  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
  */