isaacscript-common 6.6.2 → 6.6.5

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 (47) hide show
  1. package/dist/callbacks/postCustomDoorEnter.d.ts +1 -1
  2. package/dist/callbacks/postCustomDoorEnter.lua +1 -1
  3. package/dist/enums/private/SerializationBrand.d.ts +0 -4
  4. package/dist/enums/private/SerializationBrand.d.ts.map +1 -1
  5. package/dist/features/customStage/shadows.d.ts.map +1 -1
  6. package/dist/features/customStage/shadows.lua +0 -2
  7. package/dist/features/saveDataManager/merge.lua +4 -3
  8. package/dist/functions/array.d.ts.map +1 -1
  9. package/dist/functions/array.lua +1 -1
  10. package/dist/functions/deepCopy.d.ts +8 -5
  11. package/dist/functions/deepCopy.d.ts.map +1 -1
  12. package/dist/functions/deepCopy.lua +142 -38
  13. package/dist/functions/deepCopyTests.d.ts +6 -1
  14. package/dist/functions/deepCopyTests.d.ts.map +1 -1
  15. package/dist/functions/deepCopyTests.lua +19 -16
  16. package/dist/functions/log.d.ts +1 -1
  17. package/dist/functions/log.d.ts.map +1 -1
  18. package/dist/functions/log.lua +8 -4
  19. package/dist/functions/mergeTests.d.ts +7 -1
  20. package/dist/functions/mergeTests.d.ts.map +1 -1
  21. package/dist/functions/mergeTests.lua +86 -7
  22. package/dist/functions/playerIndex.d.ts +4 -0
  23. package/dist/functions/playerIndex.d.ts.map +1 -1
  24. package/dist/functions/playerIndex.lua +4 -0
  25. package/dist/functions/table.d.ts +1 -1
  26. package/dist/functions/table.lua +1 -1
  27. package/package.json +2 -2
  28. package/src/callbacks/postCursedTeleport.ts +1 -1
  29. package/src/callbacks/postCustomDoorEnter.ts +1 -1
  30. package/src/callbacks/postPlayerCollectible.ts +1 -1
  31. package/src/callbacks/postSacrifice.ts +1 -1
  32. package/src/enums/private/SerializationBrand.ts +0 -4
  33. package/src/features/customStage/shadows.ts +0 -6
  34. package/src/features/extraConsoleCommands/listCommands.ts +3 -3
  35. package/src/features/persistentEntities.ts +1 -1
  36. package/src/features/saveDataManager/merge.ts +3 -3
  37. package/src/functions/array.ts +5 -2
  38. package/src/functions/bitwise.ts +2 -2
  39. package/src/functions/deepCopy.ts +98 -19
  40. package/src/functions/deepCopyTests.ts +75 -19
  41. package/src/functions/log.ts +16 -7
  42. package/src/functions/mergeTests.ts +152 -4
  43. package/src/functions/playerIndex.ts +4 -0
  44. package/src/functions/table.ts +1 -1
  45. package/src/functions/trinketGive.ts +3 -3
  46. package/src/functions/tstlClass.ts +1 -1
  47. package/src/functions/ui.ts +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/functions/log.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAEV,UAAU,EACV,UAAU,EAEV,cAAc,EAGd,cAAc,EAGd,QAAQ,EACR,OAAO,EACR,MAAM,8BAA8B,CAAC;AA+BtC;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EAKX,kBAAkB,SAAI,GACrB,MAAM,CAiBR;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAGjD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,CAGvE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAIvD;AAED,mGAAmG;AACnG,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,GACvC,IAAI,CAEN;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA0BjE;AAED,8FAA8F;AAC9F,wBAAgB,WA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;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAiB/C;AAED,wBAAgB,MAAM,CACpB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC,SAAS,CAAC,GAC3C,IAAI,CAUN;AAED,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAQ1C;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,OAAO,EACjB,YAAY,SAAI,GACf,IAAI,CAwCN;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EACtC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GACrB,IAAI,CA0BN;AAED,iGAAiG;AACjG,wBAAgB,YAAY,CAC1B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,GACnC,IAAI,CAEN;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,GACjC,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAsB/D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,IAAI,CAGzE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CA8B5C"}
@@ -464,7 +464,7 @@ end
464
464
  -- recursively call itself if it counters a table within a table.
465
465
  --
466
466
  -- This function will only work on tables that have string keys (because it logs the keys in order,
467
- -- instead of randomly). It will throw a runtime error if it encounters a non-string key.
467
+ -- instead of randomly). It will throw a run-time error if it encounters a non-string key.
468
468
  function ____exports.logTable(luaTable, parentTables)
469
469
  if parentTables == nil then
470
470
  parentTables = 0
@@ -478,7 +478,9 @@ function ____exports.logTable(luaTable, parentTables)
478
478
  math.floor(numSpaces)
479
479
  )
480
480
  if not isTable(nil, luaTable) then
481
- ____exports.log(((indentation .. "n/a (encountered a variable of type \"") .. __TS__TypeOf(luaTable)) .. "\" instead of a table)")
481
+ (function()
482
+ ____exports.log(((indentation .. "n/a (encountered a variable of type \"") .. __TS__TypeOf(luaTable)) .. "\" instead of a table)")
483
+ end)(nil)
482
484
  return
483
485
  end
484
486
  iterateTableInOrder(
@@ -494,8 +496,10 @@ function ____exports.logTable(luaTable, parentTables)
494
496
  end
495
497
  end
496
498
  end
497
- )
498
- ____exports.log((indentation .. "The size of the table was: ") .. tostring(#luaTable))
499
+ );
500
+ (function()
501
+ ____exports.log((indentation .. "The size of the table was: ") .. tostring(#luaTable))
502
+ end)(nil)
499
503
  end
500
504
  --- Helper function to print out the differences between the entries of two tables. Note that this
501
505
  -- will only do a shallow comparison.
@@ -1,2 +1,8 @@
1
- export declare function mergeTests(): void;
1
+ /**
2
+ * Run the suite of tests that prove that the "merge" helper function works properly. (This function
3
+ * is not exported but is used internally in the save data manager.)
4
+ *
5
+ * This function is only useful if you are troubleshooting the save data manager.
6
+ */
7
+ export declare function runMergeTests(): void;
2
8
  //# sourceMappingURL=mergeTests.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTests.d.ts","sourceRoot":"","sources":["../../src/functions/mergeTests.ts"],"names":[],"mappings":"AAQA,wBAAgB,UAAU,IAAI,IAAI,CAajC"}
1
+ {"version":3,"file":"mergeTests.d.ts","sourceRoot":"","sources":["../../src/functions/mergeTests.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAgBpC"}
@@ -1,5 +1,10 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Map = ____lualib.Map
3
+ local __TS__New = ____lualib.__TS__New
1
4
  local ____exports = {}
2
- local oldTableHasUpdatedValue, newTableHasSameValue, oldTableHasUpdatedValueFromNull, oldTableHasSerializedIsaacAPIClass, oldTableHasFilledInterface, oldTableHasVector, oldTableHasVectorSerialized, oldTableHasRNG, oldTableHasRNGSerialized
5
+ local oldTableHasUpdatedValue, newTableHasSameValue, oldTableHasUpdatedValueFromNull, oldTableHasSerializedIsaacAPIClass, oldTableHasFilledChildTable, oldTableHasFilledMap, oldTableHasFilledDefaultMap, oldTableHasVector, oldTableHasVectorSerialized, oldTableHasRNG, oldTableHasRNGSerialized
6
+ local ____DefaultMap = require("classes.DefaultMap")
7
+ local DefaultMap = ____DefaultMap.DefaultMap
3
8
  local ____SerializationType = require("enums.SerializationType")
4
9
  local SerializationType = ____SerializationType.SerializationType
5
10
  local ____merge = require("features.saveDataManager.merge")
@@ -60,13 +65,13 @@ function oldTableHasSerializedIsaacAPIClass(self)
60
65
  error("The \"isSerializedIsaacAPIClass\" function says that a serialized vector is not serialized.")
61
66
  end
62
67
  end
63
- function oldTableHasFilledInterface(self)
68
+ function oldTableHasFilledChildTable(self)
64
69
  local key = "foo"
65
70
  local newValue = "baz"
66
71
  local oldTable = {foo = nil}
67
72
  local foo = {bar = newValue}
68
73
  local newTable = {foo = foo}
69
- merge(nil, oldTable, newTable, "oldTableHasFilledInterface")
74
+ merge(nil, oldTable, newTable, "oldTableHasFilledChildTable")
70
75
  local oldTableValue = oldTable[key]
71
76
  if oldTableValue == nil then
72
77
  error(("The old table's key of \"" .. key) .. "\" was not filled.")
@@ -75,6 +80,74 @@ function oldTableHasFilledInterface(self)
75
80
  error("The old table's key of \"bar\" was not filled.")
76
81
  end
77
82
  end
83
+ function oldTableHasFilledMap(self)
84
+ local v = {run = {myMap = __TS__New(Map)}}
85
+ local saveData = {run = {myMap = __TS__New(Map, {{"foo1", "bar1"}, {"foo2", "bar2"}, {"foo3", "bar3"}})}}
86
+ local serializedSaveData = deepCopy(nil, saveData, SerializationType.SERIALIZE)
87
+ merge(nil, v, serializedSaveData, "oldTableHasFilledMap")
88
+ local expectedSize = 3
89
+ if v.run.myMap.size ~= expectedSize then
90
+ error((("The size of the merged map was equal to " .. tostring(v.run.myMap.size)) .. ", but it should be equal to: ") .. tostring(expectedSize))
91
+ end
92
+ do
93
+ local key = "foo1"
94
+ local expectedValue = "bar1"
95
+ local value = v.run.myMap:get(key)
96
+ if value ~= expectedValue then
97
+ error((((("The old table's map key of \"" .. key) .. "\" was not equal to \"") .. expectedValue) .. "\" and was instead equal to: ") .. tostring(value))
98
+ end
99
+ end
100
+ do
101
+ local key = "foo2"
102
+ local expectedValue = "bar2"
103
+ local value = v.run.myMap:get(key)
104
+ if value ~= expectedValue then
105
+ error((((("The old table's map key of \"" .. key) .. "\" was not equal to \"") .. expectedValue) .. "\" and was instead equal to: ") .. tostring(value))
106
+ end
107
+ end
108
+ do
109
+ local key = "foo3"
110
+ local expectedValue = "bar3"
111
+ local value = v.run.myMap:get(key)
112
+ if value ~= expectedValue then
113
+ error((((("The old table's map key of \"" .. key) .. "\" was not equal to \"") .. expectedValue) .. "\" and was instead equal to: ") .. tostring(value))
114
+ end
115
+ end
116
+ end
117
+ function oldTableHasFilledDefaultMap(self)
118
+ local v = {run = {myDefaultMap = __TS__New(DefaultMap, "default")}}
119
+ local saveData = {run = {myDefaultMap = __TS__New(DefaultMap, "default", {{"foo1", "bar1"}, {"foo2", "bar2"}, {"foo3", "bar3"}})}}
120
+ local serializedSaveData = deepCopy(nil, saveData, SerializationType.SERIALIZE)
121
+ merge(nil, v, serializedSaveData, "oldTableHasFilledDefaultMap")
122
+ local expectedSize = 3
123
+ if v.run.myDefaultMap.size ~= expectedSize then
124
+ error((("The size of the merged default map was equal to " .. tostring(v.run.myDefaultMap.size)) .. ", but it should be equal to: ") .. tostring(expectedSize))
125
+ end
126
+ do
127
+ local key = "foo1"
128
+ local expectedValue = "bar1"
129
+ local value = v.run.myDefaultMap:get(key)
130
+ if value ~= expectedValue then
131
+ error((((("The old table's default map key of \"" .. key) .. "\" was not equal to \"") .. expectedValue) .. "\" and was instead equal to: ") .. tostring(value))
132
+ end
133
+ end
134
+ do
135
+ local key = "foo2"
136
+ local expectedValue = "bar2"
137
+ local value = v.run.myDefaultMap:get(key)
138
+ if value ~= expectedValue then
139
+ error((((("The old table's default map key of \"" .. key) .. "\" was not equal to \"") .. expectedValue) .. "\" and was instead equal to: ") .. tostring(value))
140
+ end
141
+ end
142
+ do
143
+ local key = "foo3"
144
+ local expectedValue = "bar3"
145
+ local value = v.run.myDefaultMap:get(key)
146
+ if value ~= expectedValue then
147
+ error((((("The old table's default map key of \"" .. key) .. "\" was not equal to \"") .. expectedValue) .. "\" and was instead equal to: ") .. tostring(value))
148
+ end
149
+ end
150
+ end
78
151
  function oldTableHasVector(self)
79
152
  log("Starting test: oldTableHasVector")
80
153
  local key = "foo"
@@ -108,7 +181,7 @@ function oldTableHasVectorSerialized(self)
108
181
  local oldTable = {foo = nil}
109
182
  local foo = {bar = newValue}
110
183
  local newTable = {foo = foo}
111
- local newTableSerialized = deepCopy(nil, newTable, SerializationType.SERIALIZE)
184
+ local newTableSerialized = deepCopy(nil, newTable, SerializationType.SERIALIZE, "oldTableHasVectorSerialized")
112
185
  merge(nil, oldTable, newTableSerialized, "oldTableHasVectorSerialized")
113
186
  local oldTableValue = oldTable[key]
114
187
  if oldTableValue == nil then
@@ -153,7 +226,7 @@ function oldTableHasRNGSerialized(self)
153
226
  local oldTable = {foo = nil}
154
227
  local foo = {bar = newValue}
155
228
  local newTable = {foo = foo}
156
- local newTableSerialized = deepCopy(nil, newTable, SerializationType.SERIALIZE)
229
+ local newTableSerialized = deepCopy(nil, newTable, SerializationType.SERIALIZE, "oldTableHasRNGSerialized")
157
230
  merge(nil, oldTable, newTableSerialized, "oldTableHasRNGSerialized")
158
231
  local oldTableValue = oldTable[key]
159
232
  if oldTableValue == nil then
@@ -167,12 +240,18 @@ function oldTableHasRNGSerialized(self)
167
240
  error("The old table's seed not match: " .. tostring(seed))
168
241
  end
169
242
  end
170
- function ____exports.mergeTests(self)
243
+ --- Run the suite of tests that prove that the "merge" helper function works properly. (This function
244
+ -- is not exported but is used internally in the save data manager.)
245
+ --
246
+ -- This function is only useful if you are troubleshooting the save data manager.
247
+ function ____exports.runMergeTests(self)
171
248
  oldTableHasUpdatedValue(nil)
172
249
  newTableHasSameValue(nil)
173
250
  oldTableHasUpdatedValueFromNull(nil)
174
251
  oldTableHasSerializedIsaacAPIClass(nil)
175
- oldTableHasFilledInterface(nil)
252
+ oldTableHasFilledChildTable(nil)
253
+ oldTableHasFilledMap(nil)
254
+ oldTableHasFilledDefaultMap(nil)
176
255
  oldTableHasVector(nil)
177
256
  oldTableHasVectorSerialized(nil)
178
257
  oldTableHasRNG(nil)
@@ -39,6 +39,10 @@ export declare function getPlayerFromIndex(playerIndex: PlayerIndex): EntityPlay
39
39
  * though they are technically different characters, they share the same inventory and InitSeed.) If
40
40
  * this is not desired, pass true for the `differentiateForgottenAndSoul` argument, and the RNG of
41
41
  * Spoon Bender (3) will be used for The Soul.
42
+ *
43
+ * Also note that this index doesn't work in the `POST_PLAYER_INIT` function for players 2 through
44
+ * 4. With that said, in almost all cases, you should be lazy-initializing your data structures in
45
+ * other callbacks, so this should not be an issue.
42
46
  */
43
47
  export declare function getPlayerIndex(player: EntityPlayer, differentiateForgottenAndSoul?: boolean): PlayerIndex;
44
48
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"playerIndex.d.ts","sourceRoot":"","sources":["../../src/functions/playerIndex.ts"],"names":[],"mappings":";;;AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASnD;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,YAAY,EAAE,CAU9C;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,GACvB,YAAY,GAAG,SAAS,CAG1B;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E3D"}
@@ -55,6 +55,10 @@ end
55
55
  -- though they are technically different characters, they share the same inventory and InitSeed.) If
56
56
  -- this is not desired, pass true for the `differentiateForgottenAndSoul` argument, and the RNG of
57
57
  -- Spoon Bender (3) will be used for The Soul.
58
+ --
59
+ -- Also note that this index doesn't work in the `POST_PLAYER_INIT` function for players 2 through
60
+ -- 4. With that said, in almost all cases, you should be lazy-initializing your data structures in
61
+ -- other callbacks, so this should not be an issue.
58
62
  function ____exports.getPlayerIndex(self, player, differentiateForgottenAndSoul)
59
63
  if differentiateForgottenAndSoul == nil then
60
64
  differentiateForgottenAndSoul = false
@@ -34,7 +34,7 @@ export declare function getStringsFromTable(luaTable: LuaTable<string, unknown>,
34
34
  * This function will sort the table entries based on the value of the key.
35
35
  *
36
36
  * This function will only work on tables that have number keys or string keys. It will throw a
37
- * runtime error if it encounters a key of another type.
37
+ * run-time error if it encounters a key of another type.
38
38
  *
39
39
  * @param luaTable The table to iterate over.
40
40
  * @param func The function to run for each iteration.
@@ -96,7 +96,7 @@ end
96
96
  -- This function will sort the table entries based on the value of the key.
97
97
  --
98
98
  -- This function will only work on tables that have number keys or string keys. It will throw a
99
- -- runtime error if it encounters a key of another type.
99
+ -- run-time error if it encounters a key of another type.
100
100
  --
101
101
  -- @param luaTable The table to iterate over.
102
102
  -- @param func The function to run for each iteration.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "6.6.2",
3
+ "version": "6.6.5",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "dist/index",
23
23
  "types": "dist/index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^3.0.26"
25
+ "isaac-typescript-definitions": "^3.0.27"
26
26
  }
27
27
  }
@@ -119,7 +119,7 @@ function incrementNumSacrifices(damageFlags: BitFlags<DamageFlag>) {
119
119
  const isSpikeDamage = hasFlag(damageFlags, DamageFlag.SPIKES);
120
120
 
121
121
  if (roomType === RoomType.SACRIFICE && isSpikeDamage) {
122
- v.level.numSacrifices += 1;
122
+ v.level.numSacrifices++;
123
123
  }
124
124
  }
125
125
 
@@ -219,7 +219,7 @@ function postRoomClearChanged(
219
219
  * The custom door is an `EntityEffect`. You can manually open or close the door by modifying its
220
220
  * state. (The values to use correspond to the `DoorState` enum.)
221
221
  *
222
- * This function will throw a runtime error if:
222
+ * This function will throw a run-time error if:
223
223
  * - the door slot already has a vanilla door
224
224
  * - the door slot already has a custom door
225
225
  * - the tile at the door slot does not have a wall
@@ -102,7 +102,7 @@ function collectibleCountChanged(
102
102
  } else {
103
103
  postPlayerCollectibleRemovedFire(player, collectibleType);
104
104
  }
105
- numFired += 1;
105
+ numFired++;
106
106
  });
107
107
 
108
108
  if (numFired === numCollectiblesChanged) {
@@ -56,7 +56,7 @@ function entityTakeDmgPlayer(
56
56
  const isSpikeDamage = hasFlag(damageFlags, DamageFlag.SPIKES);
57
57
 
58
58
  if (roomType === RoomType.SACRIFICE && isSpikeDamage) {
59
- v.level.numSacrifices += 1;
59
+ v.level.numSacrifices++;
60
60
  postSacrificeFire(player, v.level.numSacrifices);
61
61
  }
62
62
 
@@ -20,10 +20,6 @@ export enum SerializationBrand {
20
20
  /**
21
21
  * This is set to the value that represents the default value (instead of an empty string like the
22
22
  * other brands are).
23
- *
24
- * Default maps that use a factory function are unserializable, but do not throw runtime errors
25
- * because the merge function can derive the factory function from the already-instantiated
26
- * object.
27
23
  */
28
24
  DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE",
29
25
 
@@ -38,12 +38,6 @@ const ROOM_SHAPE_TO_SHADOW_ANIMATION: {
38
38
 
39
39
  const FADED_BLACK = Color(0, 0, 0, 0.25);
40
40
 
41
- const shadowSprite = Sprite();
42
- shadowSprite.Load(
43
- `${ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH}/stage-shadow.anm2`,
44
- true,
45
- );
46
-
47
41
  export function setShadows(customStage: CustomStage): void {
48
42
  if (customStage.shadows === undefined) {
49
43
  return;
@@ -337,7 +337,7 @@ export function cards(): void {
337
337
 
338
338
  const position = gridCoordinatesToWorldPosition(x, y);
339
339
  spawnCard(cardType as Card, position);
340
- cardType += 1;
340
+ cardType++;
341
341
  }
342
342
  }
343
343
  }
@@ -647,7 +647,7 @@ export function gridEntities(): void {
647
647
  let gridEntityTypeIndex = -1;
648
648
  for (let y = 0; y <= 6; y++) {
649
649
  for (let x = 0; x <= 12; x++) {
650
- gridEntityTypeIndex += 1;
650
+ gridEntityTypeIndex++;
651
651
  const gridEntityType = gridEntityTypes[gridEntityTypeIndex];
652
652
  if (gridEntityType === undefined) {
653
653
  return;
@@ -884,7 +884,7 @@ export function pills(): void {
884
884
  let pillColorIndex = -1;
885
885
  for (let y = 0; y <= 6; y++) {
886
886
  for (let x = 0; x <= 12; x++) {
887
- pillColorIndex += 1;
887
+ pillColorIndex++;
888
888
  const pillColor = pillColors[pillColorIndex];
889
889
  if (pillColor === undefined) {
890
890
  return;
@@ -123,7 +123,7 @@ export function spawnPersistentEntity(
123
123
  ): [Entity, int] {
124
124
  errorIfFeaturesNotInitialized(FEATURE_NAME);
125
125
 
126
- persistentEntityIndexCounter += 1;
126
+ persistentEntityIndexCounter++;
127
127
 
128
128
  const entity = spawnAndTrack(
129
129
  entityType,
@@ -8,7 +8,7 @@ import {
8
8
  isSerializedIsaacAPIClass,
9
9
  } from "../../functions/serialization";
10
10
  import { clearTable, iterateTableInOrder } from "../../functions/table";
11
- import { isTSTLMap, isTSTLSet } from "../../functions/tstlClass";
11
+ import { isDefaultMap, isTSTLMap, isTSTLSet } from "../../functions/tstlClass";
12
12
  import { isTable } from "../../functions/types";
13
13
  import { getTraversalDescription } from "../../functions/utils";
14
14
  import { SAVE_DATA_MANAGER_DEBUG } from "./saveDataManagerConstants";
@@ -65,7 +65,7 @@ export function merge(
65
65
 
66
66
  // Depending on whether we are working on a Lua table or a TypeScriptToLua object, we need to
67
67
  // iterate in a specific way.
68
- if (isTSTLMap(oldObject) || isTSTLSet(oldObject)) {
68
+ if (isTSTLMap(oldObject) || isTSTLSet(oldObject) || isDefaultMap(oldObject)) {
69
69
  mergeTSTLObject(oldObject, newTable, traversalDescription);
70
70
  } else {
71
71
  mergeTable(oldObject, newTable, traversalDescription);
@@ -118,7 +118,7 @@ function mergeTSTLObject(
118
118
  keyToUse = numberKey;
119
119
  }
120
120
 
121
- if (isTSTLMap(oldObject)) {
121
+ if (isTSTLMap(oldObject) || isDefaultMap(oldObject)) {
122
122
  let valueCopy: unknown;
123
123
  if (isTable(value)) {
124
124
  valueCopy = deepCopy(
@@ -443,7 +443,10 @@ export function isArray(object: unknown): object is unknown[] {
443
443
  return false;
444
444
  }
445
445
 
446
- const tableLength = object.length();
446
+ // Third, handle the case of an "empty" table. We cannot use the "LuaTable.length" method to
447
+ // determine this, since that will not actually return the number of keys. (It will only work
448
+ // properly for tables that are being used as arrays, which is not necessarily the case here.)
449
+ const tableLength = Object.keys(object).length;
447
450
  if (tableLength === 0) {
448
451
  return true;
449
452
  }
@@ -524,7 +527,7 @@ export function shuffleArrayInPlace<T>(
524
527
  const rng = isRNG(seedOrRNG) ? seedOrRNG : newRNG(seedOrRNG);
525
528
 
526
529
  while (currentIndex > 0) {
527
- currentIndex -= 1;
530
+ currentIndex--;
528
531
 
529
532
  const randomIndex = getRandomArrayIndex(array, rng);
530
533
  swapArrayElements(array, currentIndex, randomIndex);
@@ -57,7 +57,7 @@ export function countSetBits(n: int): int {
57
57
 
58
58
  while (n > 0) {
59
59
  n &= n - 1;
60
- count += 1;
60
+ count++;
61
61
  }
62
62
 
63
63
  return count;
@@ -72,7 +72,7 @@ export function getKBitOfN(k: int, n: int): int {
72
72
  export function getNumBitsOfN(n: int): int {
73
73
  let numBits = 0;
74
74
  while (n > 0) {
75
- numBits += 1;
75
+ numBits++;
76
76
  n >>>= 1;
77
77
  }
78
78