isaacscript-common 1.2.162 → 1.2.165

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)
@@ -1,3 +1,4 @@
1
+ export declare function capitalizeFirstLetter(string: string): string;
1
2
  export declare function stringContains(string: string, searchString: string): boolean;
2
3
  /** Helper function to trim a prefix from a string, if it exists. Returns the trimmed string. */
3
4
  export declare function trimPrefix(string: string, prefix: string): string;
@@ -4,6 +4,12 @@ local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
4
4
  local __TS__StringSlice = ____lualib.__TS__StringSlice
5
5
  local __TS__StringEndsWith = ____lualib.__TS__StringEndsWith
6
6
  local ____exports = {}
7
+ function ____exports.capitalizeFirstLetter(self, ____string)
8
+ local firstCharacter = string.sub(____string, 1, 1)
9
+ local capitalizedFirstLetter = string.upper(firstCharacter)
10
+ local restOfString = string.sub(____string, 2)
11
+ return capitalizedFirstLetter .. restOfString
12
+ end
7
13
  function ____exports.stringContains(self, ____string, searchString)
8
14
  return (string.find(____string, searchString, nil, true) or 0) - 1 ~= -1
9
15
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.162",
3
+ "version": "1.2.165",
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",