isaacscript-common 1.2.163 → 1.2.166

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.
@@ -3,7 +3,9 @@ local ____lualib = require("lualib_bundle")
3
3
  local Map = ____lualib.Map
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
- local useCardSoulOfIsaac, postPickupUpdateCollectible, v
6
+ local useCardSoulOfIsaac, postPickupUpdateCollectible, getMapIndex, v
7
+ local ____cachedClasses = require("cachedClasses")
8
+ local game = ____cachedClasses.game
7
9
  local ____featuresInitialized = require("featuresInitialized")
8
10
  local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
9
11
  local ____collectibles = require("functions.collectibles")
@@ -11,19 +13,25 @@ local setCollectibleSubType = ____collectibles.setCollectibleSubType
11
13
  local ____exports = require("features.saveDataManager.exports")
12
14
  local saveDataManager = ____exports.saveDataManager
13
15
  function useCardSoulOfIsaac(self)
14
- v.room.trackedItems:clear()
16
+ v.room.trackedCollectibles:clear()
15
17
  end
16
- function postPickupUpdateCollectible(self, pickup)
17
- if pickup.SubType == CollectibleType.COLLECTIBLE_NULL then
18
+ function postPickupUpdateCollectible(self, collectible)
19
+ if collectible.SubType == CollectibleType.COLLECTIBLE_NULL then
18
20
  return
19
21
  end
20
- local trackedCollectibleType = v.room.trackedItems:get(pickup.InitSeed)
21
- if trackedCollectibleType ~= nil and pickup.SubType ~= trackedCollectibleType then
22
- setCollectibleSubType(nil, pickup, trackedCollectibleType)
22
+ local index = getMapIndex(nil, collectible)
23
+ local trackedCollectibleType = v.room.trackedCollectibles:get(index)
24
+ if trackedCollectibleType ~= nil and collectible.SubType ~= trackedCollectibleType then
25
+ setCollectibleSubType(nil, collectible, trackedCollectibleType)
23
26
  end
24
27
  end
28
+ function getMapIndex(self, collectible)
29
+ local room = game:GetRoom()
30
+ local gridIndex = room:GetGridIndex(collectible.Position)
31
+ return (tostring(gridIndex) .. ",") .. tostring(collectible.InitSeed)
32
+ end
25
33
  local FEATURE_NAME = "prevent collectible rotation"
26
- v = {room = {trackedItems = __TS__New(Map)}}
34
+ v = {room = {trackedCollectibles = __TS__New(Map)}}
27
35
  function ____exports.preventCollectibleRotateInit(self, mod)
28
36
  saveDataManager(nil, "preventCollectibleRotate", v)
29
37
  mod:AddCallback(ModCallbacks.MC_USE_CARD, useCardSoulOfIsaac, Card.CARD_SOUL_ISAAC)
@@ -34,7 +42,8 @@ function ____exports.preventCollectibleRotate(self, collectible, collectibleType
34
42
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
35
43
  error("You cannot prevent the rotation for pickups of variant: " .. tostring(collectible.Variant))
36
44
  end
37
- v.room.trackedItems:set(collectible.InitSeed, collectibleType)
45
+ local index = getMapIndex(nil, collectible)
46
+ v.room.trackedCollectibles:set(index, collectibleType)
38
47
  postPickupUpdateCollectible(nil, collectible)
39
48
  end
40
49
  return ____exports
@@ -188,10 +188,7 @@ function ____exports.isAllPressurePlatesPushed(self)
188
188
  local pressurePlates = ____exports.getGridEntities(nil, GridEntityType.GRID_PRESSURE_PLATE)
189
189
  return __TS__ArrayEvery(
190
190
  pressurePlates,
191
- function(____, pressurePlate)
192
- local gridEntityDesc = pressurePlate:GetSaveState()
193
- return gridEntityDesc.State == 3
194
- end
191
+ function(____, pressurePlate) return pressurePlate.State == 3 end
195
192
  )
196
193
  end
197
194
  function ____exports.isGridEntityBreakableByExplosion(self, gridEntity)
@@ -354,14 +354,18 @@ function ____exports.logTable(____table, parentTables)
354
354
  if parentTables == nil then
355
355
  parentTables = 0
356
356
  end
357
- local numSpaces = (parentTables + 1) * 2
358
357
  if parentTables == 0 then
359
358
  ____exports.log("Printing out a Lua table:")
360
359
  end
360
+ local numSpaces = (parentTables + 1) * 2
361
361
  local indentation = string.rep(
362
362
  " ",
363
363
  math.floor(numSpaces)
364
364
  )
365
+ if ____table == nil then
366
+ ____exports.log(indentation .. "n/a (the table was nil)")
367
+ return
368
+ end
365
369
  local numKeys = 0
366
370
  for key, value in pairs(____table) do
367
371
  ____exports.log((((indentation .. "Key: ") .. tostring(key)) .. ", Value: ") .. tostring(value))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.163",
3
+ "version": "1.2.166",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@zamiell/typescript-to-lua": "^1.4.2",
29
- "isaac-typescript-definitions": "^1.0.369",
29
+ "isaac-typescript-definitions": "^1.0.370",
30
30
  "isaacscript-lint": "^1.0.90",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.13",