isaacscript-common 1.0.447 → 1.0.448

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,9 +1,28 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
- local ____collectibleSet = require("collectibleSet")
5
- local COLLECTIBLE_SET = ____collectibleSet.COLLECTIBLE_SET
4
+ local ____collectibles = require("functions.collectibles")
5
+ local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
6
+ local ____util = require("functions.util")
7
+ local copySet = ____util.copySet
8
+ local COLLECTIBLE_SET = __TS__New(Set)
9
+ local function initSet(self)
10
+ local itemConfig = Isaac.GetItemConfig()
11
+ do
12
+ local collectibleType = 1
13
+ while collectibleType <= getMaxCollectibleID(nil) do
14
+ local itemConfigItem = itemConfig:GetCollectible(collectibleType)
15
+ if itemConfigItem ~= nil then
16
+ COLLECTIBLE_SET:add(collectibleType)
17
+ end
18
+ collectibleType = collectibleType + 1
19
+ end
20
+ end
21
+ end
6
22
  function ____exports.getCollectibleSet(self)
7
- return __TS__New(Set, COLLECTIBLE_SET)
23
+ if COLLECTIBLE_SET.size == 0 then
24
+ initSet(nil)
25
+ end
26
+ return copySet(nil, COLLECTIBLE_SET)
8
27
  end
9
28
  return ____exports
@@ -23,8 +23,6 @@ export declare function getCollectibleMaxCharges(collectibleType: CollectibleTyp
23
23
  * ```
24
24
  */
25
25
  export declare function getCollectibleName(collectibleType: CollectibleType | int): string;
26
- /** Returns a set containing every valid collectible type in the game, including modded items. */
27
- export declare function getCollectibleSet(): Set<CollectibleType | int>;
28
26
  /** Helper function to get all of the collectible entities in the room. */
29
27
  export declare function getCollectibles(matchingSubType?: number): EntityPickup[];
30
28
  export declare function getMaxCollectibleID(): int;
@@ -6,12 +6,6 @@ local ____collectibleNameMap = require("collectibleNameMap")
6
6
  local COLLECTIBLE_NAME_MAP = ____collectibleNameMap.COLLECTIBLE_NAME_MAP
7
7
  local ____entity = require("functions.entity")
8
8
  local removeAllMatchingEntities = ____entity.removeAllMatchingEntities
9
- local ____util = require("functions.util")
10
- local copySet = ____util.copySet
11
- function ____exports.getMaxCollectibleID(self)
12
- local itemConfig = Isaac.GetItemConfig()
13
- return itemConfig:GetCollectibles().Size - 1
14
- end
15
9
  function ____exports.setCollectibleSprite(self, pickup, pngPath)
16
10
  if pickup.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
17
11
  error(
@@ -25,20 +19,6 @@ end
25
19
  COLLECTIBLE_SPRITE_LAYER = 1
26
20
  local BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png"
27
21
  local GLITCHED_ITEM_THRESHOLD = 4000000000
28
- local COLLECTIBLE_SET = __TS__New(Set)
29
- local function initSet(self)
30
- local itemConfig = Isaac.GetItemConfig()
31
- do
32
- local collectibleType = 1
33
- while collectibleType <= ____exports.getMaxCollectibleID(nil) do
34
- local itemConfigItem = itemConfig:GetCollectible(collectibleType)
35
- if itemConfigItem ~= nil then
36
- COLLECTIBLE_SET:add(collectibleType)
37
- end
38
- collectibleType = collectibleType + 1
39
- end
40
- end
41
- end
42
22
  function ____exports.changeCollectibleSubType(self, collectible, newCollectibleType)
43
23
  collectible.SubType = newCollectibleType
44
24
  local itemConfig = Isaac.GetItemConfig()
@@ -115,12 +95,6 @@ function ____exports.getCollectibleName(self, collectibleType)
115
95
  end
116
96
  return itemConfigItem.Name
117
97
  end
118
- function ____exports.getCollectibleSet(self)
119
- if COLLECTIBLE_SET.size == 0 then
120
- initSet(nil)
121
- end
122
- return copySet(nil, COLLECTIBLE_SET)
123
- end
124
98
  function ____exports.getCollectibles(self, matchingSubType)
125
99
  if matchingSubType == nil then
126
100
  matchingSubType = -1
@@ -135,6 +109,10 @@ function ____exports.getCollectibles(self, matchingSubType)
135
109
  end
136
110
  return collectibles
137
111
  end
112
+ function ____exports.getMaxCollectibleID(self)
113
+ local itemConfig = Isaac.GetItemConfig()
114
+ return itemConfig:GetCollectibles().Size - 1
115
+ end
138
116
  function ____exports.isGlitchedCollectible(self, entity)
139
117
  return ((entity.Type == EntityType.ENTITY_PICKUP) and (entity.Variant == PickupVariant.PICKUP_COLLECTIBLE)) and (entity.SubType > GLITCHED_ITEM_THRESHOLD)
140
118
  end
@@ -9,8 +9,8 @@ local PocketItemType = ____PocketItemType.PocketItemType
9
9
  local ____bitwise = require("functions.bitwise")
10
10
  local getKBitOfN = ____bitwise.getKBitOfN
11
11
  local getNumBitsOfN = ____bitwise.getNumBitsOfN
12
- local ____collectibles = require("functions.collectibles")
13
- local getCollectibleSet = ____collectibles.getCollectibleSet
12
+ local ____collectibleSet = require("functions.collectibleSet")
13
+ local getCollectibleSet = ____collectibleSet.getCollectibleSet
14
14
  function ____exports.getPlayers(self, performExclusions)
15
15
  if performExclusions == nil then
16
16
  performExclusions = false
@@ -4,9 +4,9 @@ local ____player = require("functions.player")
4
4
  local getDeathAnimationName = ____player.getDeathAnimationName
5
5
  local ____sprite = require("functions.sprite")
6
6
  local getFinalFrameOfAnimation = ____sprite.getFinalFrameOfAnimation
7
- local ____trinkets = require("functions.trinkets")
8
- local giveTrinketsBack = ____trinkets.giveTrinketsBack
9
- local temporarilyRemoveTrinkets = ____trinkets.temporarilyRemoveTrinkets
7
+ local ____trinketGive = require("functions.trinketGive")
8
+ local giveTrinketsBack = ____trinketGive.giveTrinketsBack
9
+ local temporarilyRemoveTrinkets = ____trinketGive.temporarilyRemoveTrinkets
10
10
  function ____exports.willMysteriousPaperRevive(self, player)
11
11
  local game = Game()
12
12
  local gameFrameCount = game:GetFrameCount()
@@ -0,0 +1,24 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export interface TrinketSituation {
3
+ trinketTypeRemoved: TrinketType | int;
4
+ trinket1: TrinketType | int;
5
+ trinket2: TrinketType | int;
6
+ numSmeltedTrinkets: int;
7
+ }
8
+ /**
9
+ * Helper function to temporarily remove a trinket from the player. Use this in combination with the
10
+ * `giveTrinketBack` function to take away and give back a trinket on the same frame. This function
11
+ * correctly handles multiple trinket slots and ensures that all copies of the trinket are removed,
12
+ * including smelted trinkets.
13
+ *
14
+ * Note that for simplicity, this function assumes that all smelted trinkets are non-golden.
15
+ *
16
+ * @returns Null if the player does not have the trinket, or TrinketSituation if they do.
17
+ */
18
+ export declare function temporarilyRemoveTrinkets(player: EntityPlayer, trinketType: TrinketType): TrinketSituation | undefined;
19
+ /**
20
+ * Helper function to restore the player's trinkets back to the way they were before the
21
+ * `temporarilyRemoveTrinket` function was used. It will re-smelt any smelted trinkets that were
22
+ * removed.
23
+ */
24
+ export declare function giveTrinketsBack(player: EntityPlayer, trinketSituation: TrinketSituation | undefined): void;
@@ -0,0 +1,54 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local ____constants = require("constants")
4
+ local GOLDEN_TRINKET_SHIFT = ____constants.GOLDEN_TRINKET_SHIFT
5
+ function ____exports.temporarilyRemoveTrinkets(self, player, trinketType)
6
+ if not player:HasTrinket(trinketType) then
7
+ return nil
8
+ end
9
+ local trinket1 = player:GetTrinket(0)
10
+ local trinket2 = player:GetTrinket(1)
11
+ local numTrinkets = 0
12
+ while player:HasTrinket(trinketType) do
13
+ player:TryRemoveTrinket(trinketType)
14
+ numTrinkets = numTrinkets + 1
15
+ end
16
+ local numSmeltedTrinkets = numTrinkets
17
+ local trinketWasInSlot1 = (trinket1 == trinketType) or ((trinket1 + GOLDEN_TRINKET_SHIFT) == trinketType)
18
+ if trinketWasInSlot1 then
19
+ numSmeltedTrinkets = numSmeltedTrinkets - 1
20
+ end
21
+ local trinketWasInSlot2 = (trinket2 == trinketType) or ((trinket2 + GOLDEN_TRINKET_SHIFT) == trinketType)
22
+ if trinketWasInSlot2 then
23
+ numSmeltedTrinkets = numSmeltedTrinkets - 1
24
+ end
25
+ return {trinketTypeRemoved = trinketType, trinket1 = trinket1, trinket2 = trinket2, numSmeltedTrinkets = numSmeltedTrinkets}
26
+ end
27
+ function ____exports.giveTrinketsBack(self, player, trinketSituation)
28
+ if trinketSituation == nil then
29
+ return
30
+ end
31
+ local trinket1 = player:GetTrinket(0)
32
+ local trinket2 = player:GetTrinket(1)
33
+ if trinket1 ~= TrinketType.TRINKET_NULL then
34
+ player:TryRemoveTrinket(trinket1)
35
+ end
36
+ if trinket2 ~= TrinketType.TRINKET_NULL then
37
+ player:TryRemoveTrinket(trinket2)
38
+ end
39
+ do
40
+ local i = 0
41
+ while i < trinketSituation.numSmeltedTrinkets do
42
+ player:AddTrinket(trinketSituation.trinketTypeRemoved, false)
43
+ player:UseActiveItem(CollectibleType.COLLECTIBLE_SMELTER, UseFlag.USE_NOANIM)
44
+ i = i + 1
45
+ end
46
+ end
47
+ if trinketSituation.trinket1 ~= TrinketType.TRINKET_NULL then
48
+ player:AddTrinket(trinketSituation.trinket1, false)
49
+ end
50
+ if trinketSituation.trinket2 ~= TrinketType.TRINKET_NULL then
51
+ player:AddTrinket(trinketSituation.trinket2, false)
52
+ end
53
+ end
54
+ return ____exports
@@ -0,0 +1,3 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /** Returns a set containing every valid trinket type in the game, including modded items. */
3
+ export declare function getTrinketSet(): Set<TrinketType | int>;
@@ -0,0 +1,28 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ require("lualib_bundle");
3
+ local ____exports = {}
4
+ local ____trinkets = require("functions.trinkets")
5
+ local getMaxTrinketID = ____trinkets.getMaxTrinketID
6
+ local ____util = require("functions.util")
7
+ local copySet = ____util.copySet
8
+ local TRINKET_SET = __TS__New(Set)
9
+ local function initSet(self)
10
+ local itemConfig = Isaac.GetItemConfig()
11
+ do
12
+ local trinketType = 1
13
+ while trinketType <= getMaxTrinketID(nil) do
14
+ local itemConfigTrinket = itemConfig:GetTrinket(trinketType)
15
+ if itemConfigTrinket ~= nil then
16
+ TRINKET_SET:add(trinketType)
17
+ end
18
+ trinketType = trinketType + 1
19
+ end
20
+ end
21
+ end
22
+ function ____exports.getTrinketSet(self)
23
+ if TRINKET_SET.size == 0 then
24
+ initSet(nil)
25
+ end
26
+ return copySet(nil, TRINKET_SET)
27
+ end
28
+ return ____exports
@@ -1,27 +1,4 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- export interface TrinketSituation {
3
- trinketTypeRemoved: TrinketType | int;
4
- trinket1: TrinketType | int;
5
- trinket2: TrinketType | int;
6
- numSmeltedTrinkets: int;
7
- }
8
- /**
9
- * Helper function to temporarily remove a trinket from the player. Use this in combination with the
10
- * `giveTrinketBack` function to take away and give back a trinket on the same frame. This function
11
- * correctly handles multiple trinket slots and ensures that all copies of the trinket are removed,
12
- * including smelted trinkets.
13
- *
14
- * Note that for simplicity, this function assumes that all smelted trinkets are non-golden.
15
- *
16
- * @returns Null if the player does not have the trinket, or TrinketSituation if they do.
17
- */
18
- export declare function temporarilyRemoveTrinkets(player: EntityPlayer, trinketType: TrinketType): TrinketSituation | undefined;
19
- /**
20
- * Helper function to restore the player's trinkets back to the way they were before the
21
- * `temporarilyRemoveTrinket` function was used. It will re-smelt any smelted trinkets that were
22
- * removed.
23
- */
24
- export declare function giveTrinketsBack(player: EntityPlayer, trinketSituation: TrinketSituation | undefined): void;
25
2
  export declare function getMaxTrinketID(): int;
26
3
  /** Helper function to get all of the collectible entities in the room. */
27
4
  export declare function getTrinkets(matchingSubType?: number): EntityPickup[];
@@ -35,5 +12,4 @@ export declare function getTrinkets(matchingSubType?: number): EntityPickup[];
35
12
  * ```
36
13
  */
37
14
  export declare function getTrinketName(trinketType: TrinketType | int): string;
38
- /** Returns a set containing every valid trinket type in the game, including modded items. */
39
- export declare function getTrinketSet(): Set<TrinketType | int>;
15
+ export declare function isGoldenTrinket(trinketType: TrinketType | int): boolean;
@@ -5,57 +5,6 @@ local ____constants = require("constants")
5
5
  local GOLDEN_TRINKET_SHIFT = ____constants.GOLDEN_TRINKET_SHIFT
6
6
  local ____trinketNameMap = require("trinketNameMap")
7
7
  local TRINKET_NAME_MAP = ____trinketNameMap.TRINKET_NAME_MAP
8
- local ____util = require("functions.util")
9
- local copySet = ____util.copySet
10
- function ____exports.temporarilyRemoveTrinkets(self, player, trinketType)
11
- if not player:HasTrinket(trinketType) then
12
- return nil
13
- end
14
- local trinket1 = player:GetTrinket(0)
15
- local trinket2 = player:GetTrinket(1)
16
- local numTrinkets = 0
17
- while player:HasTrinket(trinketType) do
18
- player:TryRemoveTrinket(trinketType)
19
- numTrinkets = numTrinkets + 1
20
- end
21
- local numSmeltedTrinkets = numTrinkets
22
- local trinketWasInSlot1 = (trinket1 == trinketType) or ((trinket1 + GOLDEN_TRINKET_SHIFT) == trinketType)
23
- if trinketWasInSlot1 then
24
- numSmeltedTrinkets = numSmeltedTrinkets - 1
25
- end
26
- local trinketWasInSlot2 = (trinket2 == trinketType) or ((trinket2 + GOLDEN_TRINKET_SHIFT) == trinketType)
27
- if trinketWasInSlot2 then
28
- numSmeltedTrinkets = numSmeltedTrinkets - 1
29
- end
30
- return {trinketTypeRemoved = trinketType, trinket1 = trinket1, trinket2 = trinket2, numSmeltedTrinkets = numSmeltedTrinkets}
31
- end
32
- function ____exports.giveTrinketsBack(self, player, trinketSituation)
33
- if trinketSituation == nil then
34
- return
35
- end
36
- local trinket1 = player:GetTrinket(0)
37
- local trinket2 = player:GetTrinket(1)
38
- if trinket1 ~= TrinketType.TRINKET_NULL then
39
- player:TryRemoveTrinket(trinket1)
40
- end
41
- if trinket2 ~= TrinketType.TRINKET_NULL then
42
- player:TryRemoveTrinket(trinket2)
43
- end
44
- do
45
- local i = 0
46
- while i < trinketSituation.numSmeltedTrinkets do
47
- player:AddTrinket(trinketSituation.trinketTypeRemoved, false)
48
- player:UseActiveItem(CollectibleType.COLLECTIBLE_SMELTER, UseFlag.USE_NOANIM)
49
- i = i + 1
50
- end
51
- end
52
- if trinketSituation.trinket1 ~= TrinketType.TRINKET_NULL then
53
- player:AddTrinket(trinketSituation.trinket1, false)
54
- end
55
- if trinketSituation.trinket2 ~= TrinketType.TRINKET_NULL then
56
- player:AddTrinket(trinketSituation.trinket2, false)
57
- end
58
- end
59
8
  function ____exports.getMaxTrinketID(self)
60
9
  local itemConfig = Isaac.GetItemConfig()
61
10
  return itemConfig:GetTrinkets().Size - 1
@@ -90,24 +39,7 @@ function ____exports.getTrinketName(self, trinketType)
90
39
  end
91
40
  return itemConfigItem.Name
92
41
  end
93
- local TRINKET_SET = __TS__New(Set)
94
- local function initSet(self)
95
- local itemConfig = Isaac.GetItemConfig()
96
- do
97
- local trinketType = 1
98
- while trinketType <= ____exports.getMaxTrinketID(nil) do
99
- local itemConfigTrinket = itemConfig:GetTrinket(trinketType)
100
- if itemConfigTrinket ~= nil then
101
- TRINKET_SET:add(trinketType)
102
- end
103
- trinketType = trinketType + 1
104
- end
105
- end
106
- end
107
- function ____exports.getTrinketSet(self)
108
- if TRINKET_SET.size == 0 then
109
- initSet(nil)
110
- end
111
- return copySet(nil, TRINKET_SET)
42
+ function ____exports.isGoldenTrinket(self, trinketType)
43
+ return trinketType > GOLDEN_TRINKET_SHIFT
112
44
  end
113
45
  return ____exports
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export * from "./functions/bitwise";
12
12
  export * from "./functions/card";
13
13
  export * from "./functions/charge";
14
14
  export * from "./functions/collectibles";
15
+ export * from "./functions/collectibleSet";
15
16
  export * from "./functions/color";
16
17
  export { deepCopy } from "./functions/deepCopy";
17
18
  export { deepCopyTests } from "./functions/deepCopyTests";
@@ -36,7 +37,9 @@ export * from "./functions/sprite";
36
37
  export * from "./functions/stage";
37
38
  export * from "./functions/tears";
38
39
  export * from "./functions/transformations";
40
+ export * from "./functions/trinketGive";
39
41
  export * from "./functions/trinkets";
42
+ export * from "./functions/trinketSet";
40
43
  export * from "./functions/ui";
41
44
  export * from "./functions/util";
42
45
  export * from "./functions/vector";
package/dist/index.lua CHANGED
@@ -113,6 +113,14 @@ do
113
113
  end
114
114
  end
115
115
  end
116
+ do
117
+ local ____export = require("functions.collectibleSet")
118
+ for ____exportKey, ____exportValue in pairs(____export) do
119
+ if ____exportKey ~= "default" then
120
+ ____exports[____exportKey] = ____exportValue
121
+ end
122
+ end
123
+ end
116
124
  do
117
125
  local ____export = require("functions.color")
118
126
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -299,6 +307,14 @@ do
299
307
  end
300
308
  end
301
309
  end
310
+ do
311
+ local ____export = require("functions.trinketGive")
312
+ for ____exportKey, ____exportValue in pairs(____export) do
313
+ if ____exportKey ~= "default" then
314
+ ____exports[____exportKey] = ____exportValue
315
+ end
316
+ end
317
+ end
302
318
  do
303
319
  local ____export = require("functions.trinkets")
304
320
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -307,6 +323,14 @@ do
307
323
  end
308
324
  end
309
325
  end
326
+ do
327
+ local ____export = require("functions.trinketSet")
328
+ for ____exportKey, ____exportValue in pairs(____export) do
329
+ if ____exportKey ~= "default" then
330
+ ____exports[____exportKey] = ____exportValue
331
+ end
332
+ end
333
+ end
310
334
  do
311
335
  local ____export = require("functions.ui")
312
336
  for ____exportKey, ____exportValue in pairs(____export) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.447",
3
+ "version": "1.0.448",
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
  "isaac-typescript-definitions": "^1.0.275",
29
- "isaacscript-lint": "^1.0.65",
29
+ "isaacscript-lint": "^1.0.67",
30
30
  "typedoc": "^0.22.9",
31
31
  "typescript": "4.4.4",
32
32
  "typescript-to-lua": "^1.1.1"