isaacscript-common 2.0.19 → 2.0.22

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.
@@ -1,4 +1,6 @@
1
1
  import { Card, ItemConfigCardType } from "isaac-typescript-definitions";
2
+ /** Helper function to get an array with every valid card sub-type. This includes modded cards. */
3
+ export declare function getAllCards(): Card[];
2
4
  /**
3
5
  * Helper function to get a card description from a Card enum value.
4
6
  *
@@ -38,8 +38,7 @@ function initCardObjects(self)
38
38
  __TS__New(Set)
39
39
  )
40
40
  end
41
- for ____, cardInt in ipairs(irange(nil, FIRST_CARD, MAX_CARD)) do
42
- local card = cardInt
41
+ for ____, card in ipairs(____exports.getAllCards(nil)) do
43
42
  local cardType = ____exports.getCardType(nil, card)
44
43
  local cardTypeSet = CARD_TYPE_TO_CARDS_MAP:get(cardType)
45
44
  if cardTypeSet == nil then
@@ -56,6 +55,9 @@ function initCardObjects(self)
56
55
  )
57
56
  addSetsToSet(nil, CARD_SET, cards)
58
57
  end
58
+ function ____exports.getAllCards(self)
59
+ return irange(nil, FIRST_CARD, MAX_CARD)
60
+ end
59
61
  function ____exports.getCardType(self, card)
60
62
  local cardType = CARD_TYPES[card]
61
63
  return cardType == nil and DEFAULT_CARD_TYPE or cardType
@@ -5,25 +5,21 @@ local Set = ____lualib.Set
5
5
  local ____exports = {}
6
6
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
7
  local CacheFlag = ____isaac_2Dtypescript_2Ddefinitions.CacheFlag
8
- local ____constantsMax = require("constantsMax")
9
- local FIRST_COLLECTIBLE_TYPE = ____constantsMax.FIRST_COLLECTIBLE_TYPE
10
- local MAX_COLLECTIBLE_TYPE = ____constantsMax.MAX_COLLECTIBLE_TYPE
11
8
  local ____collectibles = require("functions.collectibles")
12
9
  local collectibleHasCacheFlag = ____collectibles.collectibleHasCacheFlag
10
+ local getCollectibleTypeRange = ____collectibles.getCollectibleTypeRange
13
11
  local ____enums = require("functions.enums")
14
12
  local getEnumValues = ____enums.getEnumValues
15
13
  local ____set = require("functions.set")
16
14
  local copySet = ____set.copySet
17
15
  local getSortedSetValues = ____set.getSortedSetValues
18
16
  local ____utils = require("functions.utils")
19
- local irange = ____utils.irange
20
17
  local ____repeat = ____utils["repeat"]
21
18
  local CACHE_FLAG_TO_COLLECTIBLES_MAP = __TS__New(Map)
22
19
  local function initCacheFlagMap(self)
23
20
  for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
24
21
  local collectiblesSet = __TS__New(Set)
25
- for ____, collectibleTypeInt in ipairs(irange(nil, FIRST_COLLECTIBLE_TYPE, MAX_COLLECTIBLE_TYPE)) do
26
- local collectibleType = collectibleTypeInt
22
+ for ____, collectibleType in ipairs(getCollectibleTypeRange(nil)) do
27
23
  if collectibleHasCacheFlag(nil, collectibleType, cacheFlag) then
28
24
  collectiblesSet:add(collectibleType)
29
25
  end
@@ -4,17 +4,13 @@ local __TS__New = ____lualib.__TS__New
4
4
  local ____exports = {}
5
5
  local ____cachedClasses = require("cachedClasses")
6
6
  local itemConfig = ____cachedClasses.itemConfig
7
- local ____constantsMax = require("constantsMax")
8
- local FIRST_COLLECTIBLE_TYPE = ____constantsMax.FIRST_COLLECTIBLE_TYPE
9
- local MAX_COLLECTIBLE_TYPE = ____constantsMax.MAX_COLLECTIBLE_TYPE
7
+ local ____collectibles = require("functions.collectibles")
8
+ local getCollectibleTypeRange = ____collectibles.getCollectibleTypeRange
10
9
  local ____set = require("functions.set")
11
10
  local copySet = ____set.copySet
12
- local ____utils = require("functions.utils")
13
- local irange = ____utils.irange
14
11
  local COLLECTIBLE_SET = __TS__New(Set)
15
12
  local function initCollectibleSet(self)
16
- for ____, collectibleTypeInt in ipairs(irange(nil, FIRST_COLLECTIBLE_TYPE, MAX_COLLECTIBLE_TYPE)) do
17
- local collectibleType = collectibleTypeInt
13
+ for ____, collectibleType in ipairs(getCollectibleTypeRange(nil)) do
18
14
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
19
15
  if itemConfigItem ~= nil then
20
16
  COLLECTIBLE_SET:add(collectibleType)
@@ -8,9 +8,8 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
8
8
  local ItemConfigTag = ____isaac_2Dtypescript_2Ddefinitions.ItemConfigTag
9
9
  local ____cachedClasses = require("cachedClasses")
10
10
  local itemConfig = ____cachedClasses.itemConfig
11
- local ____constantsMax = require("constantsMax")
12
- local FIRST_COLLECTIBLE_TYPE = ____constantsMax.FIRST_COLLECTIBLE_TYPE
13
- local MAX_COLLECTIBLE_TYPE = ____constantsMax.MAX_COLLECTIBLE_TYPE
11
+ local ____collectibles = require("functions.collectibles")
12
+ local getCollectibleTypeRange = ____collectibles.getCollectibleTypeRange
14
13
  local ____enums = require("functions.enums")
15
14
  local getEnumValues = ____enums.getEnumValues
16
15
  local ____flag = require("functions.flag")
@@ -19,8 +18,6 @@ local ____player = require("functions.player")
19
18
  local getPlayerCollectibleCount = ____player.getPlayerCollectibleCount
20
19
  local ____set = require("functions.set")
21
20
  local copySet = ____set.copySet
22
- local ____utils = require("functions.utils")
23
- local irange = ____utils.irange
24
21
  function ____exports.collectibleHasTag(self, collectibleType, tag)
25
22
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
26
23
  if itemConfigItem == nil then
@@ -36,8 +33,7 @@ local function initTagMap(self)
36
33
  __TS__New(Set)
37
34
  )
38
35
  end
39
- for ____, collectibleTypeInt in ipairs(irange(nil, FIRST_COLLECTIBLE_TYPE, MAX_COLLECTIBLE_TYPE)) do
40
- local collectibleType = collectibleTypeInt
36
+ for ____, collectibleType in ipairs(getCollectibleTypeRange(nil)) do
41
37
  for ____, itemConfigTag in ipairs(getEnumValues(nil, ItemConfigTag)) do
42
38
  do
43
39
  if not ____exports.collectibleHasTag(nil, collectibleType, itemConfigTag) then
@@ -102,6 +102,15 @@ export declare function getCollectibleQuality(collectibleType: CollectibleType):
102
102
  * ```
103
103
  */
104
104
  export declare function getCollectibleTags(collectibleType: CollectibleType): BitFlags<ItemConfigTag>;
105
+ /**
106
+ * Helper function to get an array that represents the range from the first collectible type to the
107
+ * last collectible type. This will include integers that do not represent any valid collectible
108
+ * types.
109
+ *
110
+ * This function is only useful when building collectible type objects. For most purposes, you
111
+ * should use the `getCollectibleSet` helper function instead.
112
+ */
113
+ export declare function getCollectibleTypeRange(): CollectibleType[];
105
114
  /** Returns true if the item type in the item config is equal to `ItemType.ITEM_ACTIVE`. */
106
115
  export declare function isActiveCollectible(collectibleType: CollectibleType): boolean;
107
116
  /** Returns true if the collectible has a red question mark sprite. */
@@ -13,6 +13,9 @@ local game = ____cachedClasses.game
13
13
  local itemConfig = ____cachedClasses.itemConfig
14
14
  local ____constants = require("constants")
15
15
  local BLIND_ITEM_PNG_PATH = ____constants.BLIND_ITEM_PNG_PATH
16
+ local ____constantsMax = require("constantsMax")
17
+ local FIRST_COLLECTIBLE_TYPE = ____constantsMax.FIRST_COLLECTIBLE_TYPE
18
+ local MAX_COLLECTIBLE_TYPE = ____constantsMax.MAX_COLLECTIBLE_TYPE
16
19
  local ____collectibleDescriptionMap = require("maps.collectibleDescriptionMap")
17
20
  local COLLECTIBLE_DESCRIPTION_MAP = ____collectibleDescriptionMap.COLLECTIBLE_DESCRIPTION_MAP
18
21
  local DEFAULT_COLLECTIBLE_DESCRIPTION = ____collectibleDescriptionMap.DEFAULT_COLLECTIBLE_DESCRIPTION
@@ -32,6 +35,8 @@ local getRoomListIndex = ____roomData.getRoomListIndex
32
35
  local ____sprite = require("functions.sprite")
33
36
  local clearSprite = ____sprite.clearSprite
34
37
  local spriteEquals = ____sprite.spriteEquals
38
+ local ____utils = require("functions.utils")
39
+ local irange = ____utils.irange
35
40
  function initQuestionMarkSprite(self)
36
41
  local sprite = Sprite()
37
42
  sprite:Load("gfx/005.100_collectible.anm2", false)
@@ -188,6 +193,9 @@ function ____exports.getCollectibleTags(self, collectibleType)
188
193
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
189
194
  return itemConfigItem == nil and ItemConfigTagZero or itemConfigItem.Tags
190
195
  end
196
+ function ____exports.getCollectibleTypeRange(self)
197
+ return irange(nil, FIRST_COLLECTIBLE_TYPE, MAX_COLLECTIBLE_TYPE)
198
+ end
191
199
  function ____exports.isActiveCollectible(self, collectibleType)
192
200
  local itemType = ____exports.getCollectibleItemType(nil, collectibleType)
193
201
  return itemType == ItemType.ACTIVE
@@ -1,5 +1,3 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- /** For EntityType.RAGLING (246) */
2
+ /** For EntityType.SLOT (6) */
3
3
  export declare function isSlot(entity: Entity): entity is EntitySlot;
4
- /** For EntityType.RAGLING (246) */
5
- export declare function isRagling(npc: EntityNPC): npc is EntityNPCRagling;
@@ -4,7 +4,4 @@ local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
4
4
  function ____exports.isSlot(self, entity)
5
5
  return entity.Type == EntityType.SLOT
6
6
  end
7
- function ____exports.isRagling(self, npc)
8
- return npc.Type == EntityType.RAGLING
9
- end
10
7
  return ____exports
@@ -27,8 +27,6 @@ local getFilteredNewEntities = ____entity.getFilteredNewEntities
27
27
  local ____entitySpecific = require("functions.entitySpecific")
28
28
  local getNPCs = ____entitySpecific.getNPCs
29
29
  local getProjectiles = ____entitySpecific.getProjectiles
30
- local ____entityTypes = require("functions.entityTypes")
31
- local isRagling = ____entityTypes.isRagling
32
30
  function ____exports.isAliveExceptionNPC(self, npc)
33
31
  local entityTypeVariant = (tostring(npc.Type) .. ".") .. tostring(npc.Variant)
34
32
  if NON_ALIVE_NPCS_TYPE_VARIANT:has(entityTypeVariant) then
@@ -50,7 +48,7 @@ function ____exports.isDyingEggyWithNoSpidersLeft(self, npc)
50
48
  return npc.State == NpcState.SUICIDE and npc.StateFrame >= EGGY_STATE_FRAME_OF_FINAL_SPIDER
51
49
  end
52
50
  function ____exports.isRaglingDeathPatch(self, npc)
53
- return isRagling(nil, npc) and npc.Variant == RaglingVariant.RAG_MANS_RAGLING and npc.State == NpcState.SPECIAL
51
+ return npc.Type == EntityType.RAGLING and npc.Variant == RaglingVariant.RAG_MANS_RAGLING and npc.State == NpcState.SPECIAL
54
52
  end
55
53
  NON_ALIVE_NPCS_TYPE_VARIANT = __TS__New(
56
54
  Set,
@@ -1,29 +1,29 @@
1
1
  import { BatterySubType, Card, CoinSubType, CollectibleType, HeartSubType, KeySubType, PillColor, SackSubType, TrinketType } from "isaac-typescript-definitions";
2
2
  /** Helper function to get all of the battery entities in the room. */
3
- export declare function getBatteries(matchingSubType?: number): EntityPickup[];
3
+ export declare function getBatteries(matchingSubType?: number): EntityPickupBattery[];
4
4
  /** Helper function to get all of the card entities in the room. */
5
- export declare function getCards(matchingSubType?: number): EntityPickup[];
5
+ export declare function getCards(matchingSubType?: number): EntityPickupCard[];
6
6
  /**
7
7
  * Helper function to get the corresponding coin amount from a `CoinSubType`. Returns 1 for modded
8
8
  * sub-types.
9
9
  */
10
10
  export declare function getCoinValue(coinSubType: CoinSubType): int;
11
11
  /** Helper function to get all of the coin pickup entities in the room. */
12
- export declare function getCoins(matchingSubType?: number): EntityPickup[];
12
+ export declare function getCoins(matchingSubType?: number): EntityPickupCoin[];
13
13
  /** Helper function to get all of the collectible entities in the room. */
14
- export declare function getCollectibles(matchingSubType?: number): EntityPickup[];
14
+ export declare function getCollectibles(matchingSubType?: number): EntityPickupCollectible[];
15
15
  /** Helper function to get all of the heart pickup entities in the room. */
16
- export declare function getHearts(matchingSubType?: number): EntityPickup[];
16
+ export declare function getHearts(matchingSubType?: number): EntityPickupHeart[];
17
17
  /** Helper function to get all of the key pickup entities in the room. */
18
- export declare function getKeys(matchingSubType?: number): EntityPickup[];
18
+ export declare function getKeys(matchingSubType?: number): EntityPickupKey[];
19
19
  /** Helper function to get all of the pill entities in the room. */
20
- export declare function getPills(matchingSubType?: number): EntityPickup[];
20
+ export declare function getPills(matchingSubType?: number): EntityPickupPill[];
21
21
  /** Helper function to get all of the red heart pickup entities in the room. */
22
22
  export declare function getRedHearts(): EntityPickup[];
23
23
  /** Helper function to get all of the sack (i.e. grab bag) entities in the room. */
24
- export declare function getSacks(matchingSubType?: number): EntityPickup[];
24
+ export declare function getSacks(matchingSubType?: number): EntityPickupSack[];
25
25
  /** Helper function to get all of the trinket entities in the room. */
26
- export declare function getTrinkets(matchingSubType?: number): EntityPickup[];
26
+ export declare function getTrinkets(matchingSubType?: number): EntityPickupTrinket[];
27
27
  export declare function isChest(pickup: EntityPickup): boolean;
28
28
  export declare function isRedHeart(pickup: EntityPickup): boolean;
29
29
  /**
@@ -103,32 +103,30 @@ export declare function removeAllTrinkets(trinketType?: TrinketType, cap?: int):
103
103
  /**
104
104
  * Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.LIL_BATTERY` (90).
105
105
  */
106
- export declare function spawnBattery(subType: BatterySubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
107
- export declare function spawnBatteryWithSeed(subType: BatterySubType, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
106
+ export declare function spawnBattery(subType: BatterySubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickupBattery;
107
+ export declare function spawnBatteryWithSeed(subType: BatterySubType, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupBattery;
108
108
  /**
109
109
  * Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.TAROT_CARD` (300).
110
110
  */
111
- export declare function spawnCard(subType: Card, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
112
- export declare function spawnCardWithSeed(subType: Card, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
111
+ export declare function spawnCard(subType: Card, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickupCard;
112
+ export declare function spawnCardWithSeed(subType: Card, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupCard;
113
113
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.COIN` (20). */
114
- export declare function spawnCoin(subType: CoinSubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
115
- export declare function spawnCoinWithSeed(subType: CoinSubType, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
114
+ export declare function spawnCoin(subType: CoinSubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickupCoin;
115
+ export declare function spawnCoinWithSeed(subType: CoinSubType, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupCoin;
116
116
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.HEART` (10). */
117
- export declare function spawnHeart(subType: HeartSubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
118
- export declare function spawnHeartWithSeed(subType: HeartSubType, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
117
+ export declare function spawnHeart(subType: HeartSubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickupHeart;
118
+ export declare function spawnHeartWithSeed(subType: HeartSubType, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupHeart;
119
119
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.KEY` (30). */
120
- export declare function spawnKey(subType: KeySubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
121
- export declare function spawnKeyWithSeed(subType: KeySubType, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
120
+ export declare function spawnKey(subType: KeySubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickupKey;
121
+ export declare function spawnKeyWithSeed(subType: KeySubType, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupKey;
122
122
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.PILL` (70). */
123
- export declare function spawnPill(pillColor: PillColor, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
124
- export declare function spawnPillWithSeed(subType: PillColor, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
125
- /**
126
- * Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.GRAB_BAG` (69).
127
- */
128
- export declare function spawnSack(subType: SackSubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
129
- export declare function spawnSackWithSeed(subType: SackSubType, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
123
+ export declare function spawnPill(pillColor: PillColor, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickupPill;
124
+ export declare function spawnPillWithSeed(subType: PillColor, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupPill;
125
+ /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.SACK` (69). */
126
+ export declare function spawnSack(subType: SackSubType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickupSack;
127
+ export declare function spawnSackWithSeed(subType: SackSubType, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupSack;
130
128
  /**
131
129
  * Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.TRINKET` (350).
132
130
  */
133
- export declare function spawnTrinket(subType: TrinketType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickup;
134
- export declare function spawnTrinketWithSeed(subType: TrinketType, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickup;
131
+ export declare function spawnTrinket(subType: TrinketType, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityPickupTrinket;
132
+ export declare function spawnTrinketWithSeed(subType: TrinketType, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined): EntityPickupTrinket;
@@ -75,7 +75,7 @@ function ____exports.getSacks(self, matchingSubType)
75
75
  if matchingSubType == nil then
76
76
  matchingSubType = -1
77
77
  end
78
- return getPickups(nil, PickupVariant.GRAB_BAG, matchingSubType)
78
+ return getPickups(nil, PickupVariant.SACK, matchingSubType)
79
79
  end
80
80
  function ____exports.getTrinkets(self, matchingSubType)
81
81
  if matchingSubType == nil then
@@ -344,7 +344,7 @@ function ____exports.spawnSack(self, subType, position, velocity, spawner, seed)
344
344
  end
345
345
  return spawnPickup(
346
346
  nil,
347
- PickupVariant.GRAB_BAG,
347
+ PickupVariant.SACK,
348
348
  subType,
349
349
  position,
350
350
  velocity,
@@ -5,6 +5,10 @@ import { BossID, Dimension, Direction, DoorSlot, ItemPoolType, MinibossID, RoomS
5
5
  * not forget to set the `LeaveDoor` property and to prevent crashing on invalid room grid indexes.
6
6
  */
7
7
  export declare function changeRoom(roomGridIndex: int): void;
8
+ /**
9
+ * Helper function to get an array with every valid `Dimension` (not including `Dimension.CURRENT`).
10
+ */
11
+ export declare function getAllDimensions(): Dimension[];
8
12
  export declare function getAllRoomGridIndexes(): int[];
9
13
  /**
10
14
  * Helper function to get the current dimension. Most of the time, this will be `Dimension.MAIN`,
@@ -114,6 +114,9 @@ function ____exports.changeRoom(self, roomGridIndex)
114
114
  level.LeaveDoor = DoorSlot.NO_DOOR_SLOT
115
115
  game:ChangeRoom(roomGridIndex)
116
116
  end
117
+ function ____exports.getAllDimensions(self)
118
+ return erange(nil, NUM_DIMENSIONS)
119
+ end
117
120
  function ____exports.getAllRoomGridIndexes(self)
118
121
  local rooms = ____exports.getRooms(nil)
119
122
  return __TS__ArrayMap(
@@ -129,8 +132,7 @@ function ____exports.getCurrentDimension(self)
129
132
  local startingRoomGridIndex = level:GetStartingRoomIndex()
130
133
  local startingRoomDescription = level:GetRoomByIdx(startingRoomGridIndex, Dimension.CURRENT)
131
134
  local startingRoomHash = GetPtrHash(startingRoomDescription)
132
- for ____, dimensionInt in ipairs(erange(nil, NUM_DIMENSIONS)) do
133
- local dimension = dimensionInt
135
+ for ____, dimension in ipairs(____exports.getAllDimensions(nil)) do
134
136
  local dimensionRoomDescription = level:GetRoomByIdx(startingRoomGridIndex, dimension)
135
137
  local dimensionRoomHash = GetPtrHash(dimensionRoomDescription)
136
138
  if dimensionRoomHash == startingRoomHash then
@@ -347,12 +349,12 @@ function ____exports.setRoomCleared(self)
347
349
  for ____, door in ipairs(getDoors(nil)) do
348
350
  do
349
351
  if isHiddenSecretRoomDoor(nil, door) then
350
- goto __continue67
352
+ goto __continue68
351
353
  end
352
354
  openDoorFast(nil, door)
353
355
  door.ExtraVisible = false
354
356
  end
355
- ::__continue67::
357
+ ::__continue68::
356
358
  end
357
359
  sfxManager:Stop(SoundEffect.DOOR_HEAVY_OPEN)
358
360
  game:ShakeScreen(0)
@@ -7,22 +7,17 @@ local ____exports = {}
7
7
  local initCacheFlagMap, CACHE_FLAG_TO_TRINKETS_MAP
8
8
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
9
9
  local CacheFlag = ____isaac_2Dtypescript_2Ddefinitions.CacheFlag
10
- local ____constantsMax = require("constantsMax")
11
- local FIRST_TRINKET_TYPE = ____constantsMax.FIRST_TRINKET_TYPE
12
- local MAX_TRINKET_TYPE = ____constantsMax.MAX_TRINKET_TYPE
13
10
  local ____enums = require("functions.enums")
14
11
  local getEnumValues = ____enums.getEnumValues
15
12
  local ____set = require("functions.set")
16
13
  local copySet = ____set.copySet
17
14
  local ____trinkets = require("functions.trinkets")
15
+ local getTrinketTypeRange = ____trinkets.getTrinketTypeRange
18
16
  local trinketHasCacheFlag = ____trinkets.trinketHasCacheFlag
19
- local ____utils = require("functions.utils")
20
- local irange = ____utils.irange
21
17
  function initCacheFlagMap(self)
22
18
  for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
23
19
  local trinketsSet = __TS__New(Set)
24
- for ____, trinketTypeInt in ipairs(irange(nil, FIRST_TRINKET_TYPE, MAX_TRINKET_TYPE)) do
25
- local trinketType = trinketTypeInt
20
+ for ____, trinketType in ipairs(getTrinketTypeRange(nil)) do
26
21
  if trinketHasCacheFlag(nil, trinketType, cacheFlag) then
27
22
  trinketsSet:add(trinketType)
28
23
  end
@@ -4,17 +4,13 @@ local __TS__New = ____lualib.__TS__New
4
4
  local ____exports = {}
5
5
  local ____cachedClasses = require("cachedClasses")
6
6
  local itemConfig = ____cachedClasses.itemConfig
7
- local ____constantsMax = require("constantsMax")
8
- local FIRST_TRINKET_TYPE = ____constantsMax.FIRST_TRINKET_TYPE
9
- local MAX_TRINKET_TYPE = ____constantsMax.MAX_TRINKET_TYPE
10
7
  local ____set = require("functions.set")
11
8
  local copySet = ____set.copySet
12
- local ____utils = require("functions.utils")
13
- local irange = ____utils.irange
9
+ local ____trinkets = require("functions.trinkets")
10
+ local getTrinketTypeRange = ____trinkets.getTrinketTypeRange
14
11
  local TRINKET_SET = __TS__New(Set)
15
12
  local function initTrinketSet(self)
16
- for ____, trinketTypeInt in ipairs(irange(nil, FIRST_TRINKET_TYPE, MAX_TRINKET_TYPE)) do
17
- local trinketType = trinketTypeInt
13
+ for ____, trinketType in ipairs(getTrinketTypeRange(nil)) do
18
14
  local itemConfigTrinket = itemConfig:GetTrinket(trinketType)
19
15
  if itemConfigTrinket ~= nil then
20
16
  TRINKET_SET:add(trinketType)
@@ -38,6 +38,14 @@ export declare function getTrinketDescription(trinketType: TrinketType): string;
38
38
  * ```
39
39
  */
40
40
  export declare function getTrinketName(trinketType: TrinketType): string;
41
+ /**
42
+ * Helper function to get an array that represents the range from the first trinket type to the last
43
+ * trinket type. This will include integers that do not represent any valid trinket types.
44
+ *
45
+ * This function is only useful when building trinket type objects. For most purposes, you should
46
+ * use the `getTrinketSet` helper function instead.
47
+ */
48
+ export declare function getTrinketTypeRange(): TrinketType[];
41
49
  /**
42
50
  * Returns whether or not the player can hold an additional trinket, beyond what they are currently
43
51
  * carrying. This takes into account items that modify the max number of trinkets, like Mom's Purse.
@@ -5,6 +5,9 @@ local TrinketSlot = ____isaac_2Dtypescript_2Ddefinitions.TrinketSlot
5
5
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
6
6
  local ____cachedClasses = require("cachedClasses")
7
7
  local itemConfig = ____cachedClasses.itemConfig
8
+ local ____constantsMax = require("constantsMax")
9
+ local FIRST_TRINKET_TYPE = ____constantsMax.FIRST_TRINKET_TYPE
10
+ local MAX_TRINKET_TYPE = ____constantsMax.MAX_TRINKET_TYPE
8
11
  local ____trinketDescriptionMap = require("maps.trinketDescriptionMap")
9
12
  local DEFAULT_TRINKET_DESCRIPTION = ____trinketDescriptionMap.DEFAULT_TRINKET_DESCRIPTION
10
13
  local TRINKET_DESCRIPTION_MAP = ____trinketDescriptionMap.TRINKET_DESCRIPTION_MAP
@@ -21,6 +24,8 @@ local ____player = require("functions.player")
21
24
  local isCharacter = ____player.isCharacter
22
25
  local ____sprite = require("functions.sprite")
23
26
  local clearSprite = ____sprite.clearSprite
27
+ local ____utils = require("functions.utils")
28
+ local irange = ____utils.irange
24
29
  local GOLDEN_TRINKET_FLAG = 32767
25
30
  local GOLDEN_TRINKET_ADJUSTMENT = 32768
26
31
  local TRINKET_SPRITE_LAYER = 0
@@ -64,6 +69,9 @@ function ____exports.getTrinketName(self, trinketType)
64
69
  end
65
70
  return DEFAULT_TRINKET_NAME
66
71
  end
72
+ function ____exports.getTrinketTypeRange(self)
73
+ return irange(nil, FIRST_TRINKET_TYPE, MAX_TRINKET_TYPE)
74
+ end
67
75
  function ____exports.hasOpenTrinketSlot(self, player)
68
76
  if isCharacter(nil, player, PlayerType.THE_SOUL_B) then
69
77
  return false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "2.0.19",
3
+ "version": "2.0.22",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,10 +25,10 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "dependencies": {
28
- "isaac-typescript-definitions": "^2.0.35"
28
+ "isaac-typescript-definitions": "^2.0.38"
29
29
  },
30
30
  "devDependencies": {
31
- "isaacscript-lint": "^1.0.156",
31
+ "isaacscript-lint": "^1.0.157",
32
32
  "isaacscript-spell": "^1.0.3",
33
33
  "isaacscript-tsconfig": "^1.1.16",
34
34
  "npm-check-updates": "^13.0.1",