isaacscript-common 1.2.16 → 1.2.17

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.
@@ -10,9 +10,10 @@ local copySet = ____set.copySet
10
10
  local COLLECTIBLE_SET = __TS__New(Set)
11
11
  local function initCollectibleSet(self)
12
12
  local itemConfig = Isaac.GetItemConfig()
13
+ local maxCollectibleID = getMaxCollectibleID(nil)
13
14
  do
14
15
  local collectibleType = 1
15
- while collectibleType <= getMaxCollectibleID(nil) do
16
+ while collectibleType <= maxCollectibleID do
16
17
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
17
18
  if itemConfigItem ~= nil then
18
19
  COLLECTIBLE_SET:add(collectibleType)
@@ -1,5 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  export declare function collectibleHasTag(collectibleType: CollectibleType | int, tag: ItemConfigTag): boolean;
3
+ export declare function collectibleHasCacheFlag(collectibleType: CollectibleType | int, cacheFlag: CacheFlag): boolean;
3
4
  /**
4
5
  * Helper function to get the in-game description for a collectible. Returns "Unknown" if the
5
6
  * provided collectible type was not valid.
@@ -14,6 +14,8 @@ local COLLECTIBLE_NAME_MAP = ____collectibleNameMap.COLLECTIBLE_NAME_MAP
14
14
  local ____entity = require("functions.entity")
15
15
  local getPickups = ____entity.getPickups
16
16
  local removeAllPickups = ____entity.removeAllPickups
17
+ local ____flag = require("functions.flag")
18
+ local hasFlag = ____flag.hasFlag
17
19
  local ____sprite = require("functions.sprite")
18
20
  local clearSprite = ____sprite.clearSprite
19
21
  function ____exports.setCollectibleSprite(self, collectible, pngPath)
@@ -39,6 +41,14 @@ function ____exports.collectibleHasTag(self, collectibleType, tag)
39
41
  end
40
42
  return itemConfigItem:HasTags(tag)
41
43
  end
44
+ function ____exports.collectibleHasCacheFlag(self, collectibleType, cacheFlag)
45
+ local itemConfig = Isaac.GetItemConfig()
46
+ local itemConfigItem = itemConfig:GetCollectible(collectibleType)
47
+ if itemConfigItem == nil then
48
+ return false
49
+ end
50
+ return hasFlag(nil, itemConfigItem.CacheFlags, cacheFlag)
51
+ end
42
52
  function ____exports.getCollectibleDescription(self, collectibleType)
43
53
  local itemConfig = Isaac.GetItemConfig()
44
54
  local defaultDescription = "Unknown"
@@ -11,12 +11,13 @@ local ____collectibles = require("functions.collectibles")
11
11
  local collectibleHasTag = ____collectibles.collectibleHasTag
12
12
  local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
13
13
  function initMaps(self)
14
+ local maxCollectibleID = getMaxCollectibleID(nil)
14
15
  for ____, playerForm in __TS__Iterator(____exports.TRANSFORMATION_TO_TAG_MAP:keys()) do
15
16
  ____exports.TRANSFORMATION_TO_ITEMS_MAP:set(playerForm, {})
16
17
  end
17
18
  do
18
19
  local collectibleType = 1
19
- while collectibleType <= getMaxCollectibleID(nil) do
20
+ while collectibleType <= maxCollectibleID do
20
21
  for ____, ____value in __TS__Iterator(____exports.TRANSFORMATION_TO_TAG_MAP:entries()) do
21
22
  local playerForm = ____value[1]
22
23
  local tag = ____value[2]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.16",
3
+ "version": "1.2.17",
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.0",
29
- "isaac-typescript-definitions": "^1.0.337",
29
+ "isaac-typescript-definitions": "^1.0.338",
30
30
  "isaacscript-lint": "^1.0.79",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.11",