isaacscript-common 1.2.15 → 1.2.19
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.
- package/dist/functions/collectibleCacheFlag.d.ts +6 -0
- package/dist/functions/collectibleCacheFlag.lua +41 -0
- package/dist/functions/collectibleSet.lua +2 -1
- package/dist/functions/collectibles.d.ts +1 -0
- package/dist/functions/collectibles.lua +10 -0
- package/dist/functions/pills.d.ts +22 -0
- package/dist/functions/pills.lua +16 -0
- package/dist/functions/player.d.ts +16 -0
- package/dist/functions/player.lua +47 -30
- package/dist/functions/transformations.d.ts +2 -1
- package/dist/functions/transformations.lua +79 -12
- package/dist/functions/util.d.ts +1 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.lua +8 -8
- package/dist/maps/transformationMaps.lua +2 -1
- package/dist/types/PillEffectClass.d.ts +1 -0
- package/dist/types/PillEffectClass.lua +1 -0
- package/dist/types/PillEffectType.d.ts +1 -0
- package/dist/types/PillEffectType.lua +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/**
|
|
3
|
+
* Returns a set containing every collectible type with the given cache flag, including modded
|
|
4
|
+
* items.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getCollectiblesForCacheFlag(cacheFlag: CacheFlag): Set<CollectibleType | int>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____lualib = require("lualib_bundle")
|
|
3
|
+
local Map = ____lualib.Map
|
|
4
|
+
local __TS__New = ____lualib.__TS__New
|
|
5
|
+
local Set = ____lualib.Set
|
|
6
|
+
local ____exports = {}
|
|
7
|
+
local ____collectibles = require("functions.collectibles")
|
|
8
|
+
local collectibleHasCacheFlag = ____collectibles.collectibleHasCacheFlag
|
|
9
|
+
local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
|
|
10
|
+
local ____set = require("functions.set")
|
|
11
|
+
local copySet = ____set.copySet
|
|
12
|
+
local ____util = require("functions.util")
|
|
13
|
+
local getEnumValues = ____util.getEnumValues
|
|
14
|
+
local CACHE_FLAG_TO_COLLECTIBLES_MAP = __TS__New(Map)
|
|
15
|
+
local function initCacheFlagMap(self)
|
|
16
|
+
local maxCollectibleID = getMaxCollectibleID(nil)
|
|
17
|
+
for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
|
|
18
|
+
local collectiblesSet = __TS__New(Set)
|
|
19
|
+
do
|
|
20
|
+
local collectibleType = 1
|
|
21
|
+
while collectibleType <= maxCollectibleID do
|
|
22
|
+
if collectibleHasCacheFlag(nil, collectibleType, cacheFlag) then
|
|
23
|
+
collectiblesSet:add(collectibleType)
|
|
24
|
+
end
|
|
25
|
+
collectibleType = collectibleType + 1
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
CACHE_FLAG_TO_COLLECTIBLES_MAP:set(cacheFlag, collectiblesSet)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
function ____exports.getCollectiblesForCacheFlag(self, cacheFlag)
|
|
32
|
+
if CACHE_FLAG_TO_COLLECTIBLES_MAP.size == 0 then
|
|
33
|
+
initCacheFlagMap(nil)
|
|
34
|
+
end
|
|
35
|
+
local collectiblesSet = CACHE_FLAG_TO_COLLECTIBLES_MAP:get(cacheFlag)
|
|
36
|
+
if collectiblesSet == nil then
|
|
37
|
+
return __TS__New(Set)
|
|
38
|
+
end
|
|
39
|
+
return copySet(nil, collectiblesSet)
|
|
40
|
+
end
|
|
41
|
+
return ____exports
|
|
@@ -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 <=
|
|
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"
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
import { PillEffectClass } from "../types/PillEffectClass";
|
|
3
|
+
import { PillEffectType } from "../types/PillEffectType";
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to get a pill effect class from a PillEffect enum value. In this context, the
|
|
6
|
+
* class is equal to the numerical prefix in the "class" tag in the "pocketitems.xml" file. Use the
|
|
7
|
+
* `getPillEffectType` helper function to determine whether or not the pill effect is positive,
|
|
8
|
+
* negative, or neutral.
|
|
9
|
+
*
|
|
10
|
+
* Due to limitations in the API, this function will not work properly for modded pill effects, and
|
|
11
|
+
* will always return `DEFAULT_PILL_EFFECT_CLASS` in those cases.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getPillEffectClass(pillEffect: PillEffect | int): PillEffectClass;
|
|
2
14
|
/**
|
|
3
15
|
* Helper function to get a pill effect name from a PillEffect enum value.
|
|
4
16
|
*
|
|
@@ -9,3 +21,13 @@
|
|
|
9
21
|
* ```
|
|
10
22
|
*/
|
|
11
23
|
export declare function getPillEffectName(pillEffect: PillEffect | int): string;
|
|
24
|
+
/**
|
|
25
|
+
* Helper function to get a pill effect type from a PillEffect enum value. In this context, the
|
|
26
|
+
* type is equal to positive, negative, or neutral. This is derived from the suffix of the the
|
|
27
|
+
* "class" tag in the "pocketitems.xml" file. Use the `getPillEffectClass` helper function to
|
|
28
|
+
* determine the "power" of the pill.
|
|
29
|
+
*
|
|
30
|
+
* Due to limitations in the API, this function will not work properly for modded pill effects, and
|
|
31
|
+
* will always return `DEFAULT_PILL_EFFECT_TYPE` in those cases.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getPillEffectType(pillEffect: PillEffect | int): PillEffectType;
|
package/dist/functions/pills.lua
CHANGED
|
@@ -2,8 +2,20 @@
|
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
3
|
local Map = ____lualib.Map
|
|
4
4
|
local ____exports = {}
|
|
5
|
+
local ____pillEffectClassMap = require("maps.pillEffectClassMap")
|
|
6
|
+
local PILL_EFFECT_CLASS_MAP = ____pillEffectClassMap.PILL_EFFECT_CLASS_MAP
|
|
5
7
|
local ____pillEffectNameMap = require("maps.pillEffectNameMap")
|
|
6
8
|
local PILL_EFFECT_NAME_MAP = ____pillEffectNameMap.PILL_EFFECT_NAME_MAP
|
|
9
|
+
local ____pillEffectTypeMap = require("maps.pillEffectTypeMap")
|
|
10
|
+
local PILL_EFFECT_TYPE_MAP = ____pillEffectTypeMap.PILL_EFFECT_TYPE_MAP
|
|
11
|
+
local ____PillEffectClass = require("types.PillEffectClass")
|
|
12
|
+
local DEFAULT_PILL_EFFECT_CLASS = ____PillEffectClass.DEFAULT_PILL_EFFECT_CLASS
|
|
13
|
+
local ____PillEffectType = require("types.PillEffectType")
|
|
14
|
+
local DEFAULT_PILL_EFFECT_TYPE = ____PillEffectType.DEFAULT_PILL_EFFECT_TYPE
|
|
15
|
+
function ____exports.getPillEffectClass(self, pillEffect)
|
|
16
|
+
local pillEffectClass = PILL_EFFECT_CLASS_MAP:get(pillEffect)
|
|
17
|
+
return pillEffectClass == nil and DEFAULT_PILL_EFFECT_CLASS or pillEffectClass
|
|
18
|
+
end
|
|
7
19
|
function ____exports.getPillEffectName(self, pillEffect)
|
|
8
20
|
local itemConfig = Isaac.GetItemConfig()
|
|
9
21
|
local defaultName = "Unknown"
|
|
@@ -20,4 +32,8 @@ function ____exports.getPillEffectName(self, pillEffect)
|
|
|
20
32
|
end
|
|
21
33
|
return itemConfigPillEffect.Name
|
|
22
34
|
end
|
|
35
|
+
function ____exports.getPillEffectType(self, pillEffect)
|
|
36
|
+
local pillEffectClass = PILL_EFFECT_TYPE_MAP:get(pillEffect)
|
|
37
|
+
return pillEffectClass == nil and DEFAULT_PILL_EFFECT_TYPE or pillEffectClass
|
|
38
|
+
end
|
|
23
39
|
return ____exports
|
|
@@ -81,6 +81,22 @@ export declare function getNewestPlayer(): EntityPlayer;
|
|
|
81
81
|
* hearts and 3 broken hearts, then this function would return 6 (i.e. 12 - 1 - 2 - 3).
|
|
82
82
|
*/
|
|
83
83
|
export declare function getPlayerAvailableHeartSlots(player: EntityPlayer): int;
|
|
84
|
+
/**
|
|
85
|
+
* Returns an array containing every collectible type that the player has that matches the provided
|
|
86
|
+
* CacheFlag.
|
|
87
|
+
*
|
|
88
|
+
* For example, if a player has one Lord of the Pit and two Transcendences, then this function would
|
|
89
|
+
* return:
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* [
|
|
93
|
+
* CollectibleType.COLLECTIBLE_LORD_OF_THE_PIT,
|
|
94
|
+
* CollectibleType.COLLECTIBLE_TRANSCENDENCE,
|
|
95
|
+
* CollectibleType.COLLECTIBLE_TRANSCENDENCE,
|
|
96
|
+
* ]
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare function getPlayerCollectiblesForCacheFlag(player: EntityPlayer, cacheFlag: CacheFlag): Array<CollectibleType | int>;
|
|
84
100
|
/**
|
|
85
101
|
* Returns the maximum heart containers that the provided character can have. Normally, this is 12,
|
|
86
102
|
* but with Keeper it is 3, with Tainted Keeper it is 2. Does not account for Birthright or Mother's
|
|
@@ -3,10 +3,10 @@ local ____lualib = require("lualib_bundle")
|
|
|
3
3
|
local Set = ____lualib.Set
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
5
|
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
6
|
+
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
7
|
+
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
6
8
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
7
9
|
local Map = ____lualib.Map
|
|
8
|
-
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
9
|
-
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
10
10
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
11
11
|
local ____exports = {}
|
|
12
12
|
local getAdjustedPlayerName, isTaintedModded, EXCLUDED_CHARACTERS
|
|
@@ -25,6 +25,8 @@ local arraySum = ____array.arraySum
|
|
|
25
25
|
local ____bitwise = require("functions.bitwise")
|
|
26
26
|
local getKBitOfN = ____bitwise.getKBitOfN
|
|
27
27
|
local getNumBitsOfN = ____bitwise.getNumBitsOfN
|
|
28
|
+
local ____collectibleCacheFlag = require("functions.collectibleCacheFlag")
|
|
29
|
+
local getCollectiblesForCacheFlag = ____collectibleCacheFlag.getCollectiblesForCacheFlag
|
|
28
30
|
local ____collectibles = require("functions.collectibles")
|
|
29
31
|
local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
|
|
30
32
|
local ____collectibleSet = require("functions.collectibleSet")
|
|
@@ -72,39 +74,39 @@ end
|
|
|
72
74
|
function getAdjustedPlayerName(self, player)
|
|
73
75
|
local character = player:GetPlayerType()
|
|
74
76
|
repeat
|
|
75
|
-
local
|
|
76
|
-
local
|
|
77
|
-
if
|
|
77
|
+
local ____switch75 = character
|
|
78
|
+
local ____cond75 = ____switch75 == PlayerType.PLAYER_BLUEBABY or ____switch75 == PlayerType.PLAYER_BLUEBABY_B
|
|
79
|
+
if ____cond75 then
|
|
78
80
|
do
|
|
79
81
|
return "Blue Baby"
|
|
80
82
|
end
|
|
81
83
|
end
|
|
82
|
-
|
|
83
|
-
if
|
|
84
|
+
____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_LAZARUS2
|
|
85
|
+
if ____cond75 then
|
|
84
86
|
do
|
|
85
87
|
return "Lazarus II"
|
|
86
88
|
end
|
|
87
89
|
end
|
|
88
|
-
|
|
89
|
-
if
|
|
90
|
+
____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_BLACKJUDAS
|
|
91
|
+
if ____cond75 then
|
|
90
92
|
do
|
|
91
93
|
return "Dark Judas"
|
|
92
94
|
end
|
|
93
95
|
end
|
|
94
|
-
|
|
95
|
-
if
|
|
96
|
+
____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_JACOB
|
|
97
|
+
if ____cond75 then
|
|
96
98
|
do
|
|
97
99
|
return "Jacob & Esau"
|
|
98
100
|
end
|
|
99
101
|
end
|
|
100
|
-
|
|
101
|
-
if
|
|
102
|
+
____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_LAZARUS2_B
|
|
103
|
+
if ____cond75 then
|
|
102
104
|
do
|
|
103
105
|
return "Dead Tainted Lazarus"
|
|
104
106
|
end
|
|
105
107
|
end
|
|
106
|
-
|
|
107
|
-
if
|
|
108
|
+
____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_JACOB2_B
|
|
109
|
+
if ____cond75 then
|
|
108
110
|
do
|
|
109
111
|
return "Dead Tainted Jacob"
|
|
110
112
|
end
|
|
@@ -128,18 +130,18 @@ function ____exports.getPlayers(self, performExclusions)
|
|
|
128
130
|
do
|
|
129
131
|
local player = Isaac.GetPlayer(i)
|
|
130
132
|
if player == nil then
|
|
131
|
-
goto
|
|
133
|
+
goto __continue85
|
|
132
134
|
end
|
|
133
135
|
if ____exports.isChildPlayer(nil, player) then
|
|
134
|
-
goto
|
|
136
|
+
goto __continue85
|
|
135
137
|
end
|
|
136
138
|
local character = player:GetPlayerType()
|
|
137
139
|
if performExclusions and EXCLUDED_CHARACTERS:has(character) then
|
|
138
|
-
goto
|
|
140
|
+
goto __continue85
|
|
139
141
|
end
|
|
140
142
|
__TS__ArrayPush(players, player)
|
|
141
143
|
end
|
|
142
|
-
::
|
|
144
|
+
::__continue85::
|
|
143
145
|
i = i + 1
|
|
144
146
|
end
|
|
145
147
|
end
|
|
@@ -330,6 +332,21 @@ function ____exports.getPlayerAvailableHeartSlots(self, player)
|
|
|
330
332
|
local totalOccupiedHeartSlots = totalHeartContainers + brokenHearts
|
|
331
333
|
return maxHeartContainers - totalOccupiedHeartSlots
|
|
332
334
|
end
|
|
335
|
+
function ____exports.getPlayerCollectiblesForCacheFlag(self, player, cacheFlag)
|
|
336
|
+
local collectiblesForCacheFlag = getCollectiblesForCacheFlag(nil, cacheFlag)
|
|
337
|
+
local playerCollectibles = {}
|
|
338
|
+
for ____, collectibleType in __TS__Iterator(collectiblesForCacheFlag:values()) do
|
|
339
|
+
local numCollectibles = player:GetCollectibleNum(collectibleType)
|
|
340
|
+
do
|
|
341
|
+
local i = 0
|
|
342
|
+
while i < numCollectibles do
|
|
343
|
+
__TS__ArrayPush(playerCollectibles, collectibleType)
|
|
344
|
+
i = i + 1
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
return playerCollectibles
|
|
349
|
+
end
|
|
333
350
|
function ____exports.getPlayerCloserThan(self, position, distance)
|
|
334
351
|
for ____, player in ipairs(____exports.getPlayers(nil)) do
|
|
335
352
|
if player.Position:Distance(position) <= distance then
|
|
@@ -367,14 +384,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
|
|
|
367
384
|
do
|
|
368
385
|
local player = Isaac.GetPlayer(i)
|
|
369
386
|
if player == nil then
|
|
370
|
-
goto
|
|
387
|
+
goto __continue66
|
|
371
388
|
end
|
|
372
389
|
local playerHash = GetPtrHash(player)
|
|
373
390
|
if playerHash == playerToFindHash then
|
|
374
391
|
return i
|
|
375
392
|
end
|
|
376
393
|
end
|
|
377
|
-
::
|
|
394
|
+
::__continue66::
|
|
378
395
|
i = i + 1
|
|
379
396
|
end
|
|
380
397
|
end
|
|
@@ -544,9 +561,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
544
561
|
itemPool:RemoveCollectible(collectibleType)
|
|
545
562
|
end
|
|
546
563
|
repeat
|
|
547
|
-
local
|
|
548
|
-
local
|
|
549
|
-
if
|
|
564
|
+
local ____switch128 = activeSlot
|
|
565
|
+
local ____cond128 = ____switch128 == ActiveSlot.SLOT_PRIMARY
|
|
566
|
+
if ____cond128 then
|
|
550
567
|
do
|
|
551
568
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
552
569
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -555,8 +572,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
555
572
|
break
|
|
556
573
|
end
|
|
557
574
|
end
|
|
558
|
-
|
|
559
|
-
if
|
|
575
|
+
____cond128 = ____cond128 or ____switch128 == ActiveSlot.SLOT_SECONDARY
|
|
576
|
+
if ____cond128 then
|
|
560
577
|
do
|
|
561
578
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
562
579
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -571,16 +588,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
571
588
|
break
|
|
572
589
|
end
|
|
573
590
|
end
|
|
574
|
-
|
|
575
|
-
if
|
|
591
|
+
____cond128 = ____cond128 or ____switch128 == ActiveSlot.SLOT_POCKET
|
|
592
|
+
if ____cond128 then
|
|
576
593
|
do
|
|
577
594
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
578
595
|
player:SetActiveCharge(charge, activeSlot)
|
|
579
596
|
break
|
|
580
597
|
end
|
|
581
598
|
end
|
|
582
|
-
|
|
583
|
-
if
|
|
599
|
+
____cond128 = ____cond128 or ____switch128 == ActiveSlot.SLOT_POCKET2
|
|
600
|
+
if ____cond128 then
|
|
584
601
|
do
|
|
585
602
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
586
603
|
break
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
export declare function getCollectibleTypesForTransformation(playerForm: PlayerForm): Set<PlayerForm>;
|
|
2
3
|
/** Returns the number of items that a player has towards a particular transformation. */
|
|
3
4
|
export declare function getPlayerNumTransformationCollectibles(player: EntityPlayer, playerForm: PlayerForm): int;
|
|
4
|
-
export declare function getTransformationsForItem(collectibleType: CollectibleType | int): PlayerForm[];
|
|
5
5
|
/**
|
|
6
6
|
* Helper function to get a transformation name from a PlayerForm enum.
|
|
7
7
|
*
|
|
@@ -12,3 +12,4 @@ export declare function getTransformationsForItem(collectibleType: CollectibleTy
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export declare function getTransformationName(transformation: PlayerForm): string;
|
|
15
|
+
export declare function getTransformationsForCollectibleType(collectibleType: CollectibleType | int): Set<PlayerForm>;
|
|
@@ -1,37 +1,104 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
3
|
local Map = ____lualib.Map
|
|
4
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
5
|
local Set = ____lualib.Set
|
|
6
|
+
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
5
7
|
local ____exports = {}
|
|
6
|
-
local ____transformationMaps = require("maps.transformationMaps")
|
|
7
|
-
local ITEM_TO_TRANSFORMATION_MAP = ____transformationMaps.ITEM_TO_TRANSFORMATION_MAP
|
|
8
|
-
local TRANSFORMATIONS_NOT_BASED_ON_ITEMS = ____transformationMaps.TRANSFORMATIONS_NOT_BASED_ON_ITEMS
|
|
9
|
-
local TRANSFORMATION_TO_ITEMS_MAP = ____transformationMaps.TRANSFORMATION_TO_ITEMS_MAP
|
|
10
8
|
local ____transformationNameMap = require("maps.transformationNameMap")
|
|
11
9
|
local TRANSFORMATION_NAME_MAP = ____transformationNameMap.TRANSFORMATION_NAME_MAP
|
|
12
|
-
local
|
|
13
|
-
local
|
|
10
|
+
local ____collectibles = require("functions.collectibles")
|
|
11
|
+
local collectibleHasTag = ____collectibles.collectibleHasTag
|
|
12
|
+
local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
|
|
13
|
+
local ____set = require("functions.set")
|
|
14
|
+
local copySet = ____set.copySet
|
|
15
|
+
local TRANSFORMATION_TO_TAG_MAP = __TS__New(Map, {
|
|
16
|
+
{PlayerForm.PLAYERFORM_GUPPY, 32},
|
|
17
|
+
{PlayerForm.PLAYERFORM_LORD_OF_THE_FLIES, 64},
|
|
18
|
+
{PlayerForm.PLAYERFORM_MUSHROOM, 256},
|
|
19
|
+
{PlayerForm.PLAYERFORM_ANGEL, 1024},
|
|
20
|
+
{PlayerForm.PLAYERFORM_BOB, 128},
|
|
21
|
+
{PlayerForm.PLAYERFORM_DRUGS, 2},
|
|
22
|
+
{PlayerForm.PLAYERFORM_MOM, 4},
|
|
23
|
+
{PlayerForm.PLAYERFORM_BABY, 512},
|
|
24
|
+
{PlayerForm.PLAYERFORM_EVIL_ANGEL, 2048},
|
|
25
|
+
{PlayerForm.PLAYERFORM_POOP, 4096},
|
|
26
|
+
{PlayerForm.PLAYERFORM_BOOK_WORM, 8192},
|
|
27
|
+
{PlayerForm.PLAYERFORM_SPIDERBABY, 16384}
|
|
28
|
+
})
|
|
29
|
+
local TRANSFORMATIONS_NOT_BASED_ON_ITEMS = __TS__New(Set, {PlayerForm.PLAYERFORM_ADULTHOOD, PlayerForm.PLAYERFORM_STOMPY, PlayerForm.PLAYERFORM_FLIGHT})
|
|
30
|
+
local TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP = __TS__New(Map)
|
|
31
|
+
local COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP = __TS__New(Map)
|
|
32
|
+
local function initMaps(self)
|
|
33
|
+
local maxCollectibleID = getMaxCollectibleID(nil)
|
|
34
|
+
for ____, playerForm in __TS__Iterator(TRANSFORMATION_TO_TAG_MAP:keys()) do
|
|
35
|
+
TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:set(
|
|
36
|
+
playerForm,
|
|
37
|
+
__TS__New(Set)
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
do
|
|
41
|
+
local collectibleType = 1
|
|
42
|
+
while collectibleType <= maxCollectibleID do
|
|
43
|
+
for ____, ____value in __TS__Iterator(TRANSFORMATION_TO_TAG_MAP:entries()) do
|
|
44
|
+
local playerForm = ____value[1]
|
|
45
|
+
local tag = ____value[2]
|
|
46
|
+
do
|
|
47
|
+
if not collectibleHasTag(nil, collectibleType, tag) then
|
|
48
|
+
goto __continue6
|
|
49
|
+
end
|
|
50
|
+
local collectibleTypesSet = TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:get(playerForm)
|
|
51
|
+
if collectibleTypesSet == nil then
|
|
52
|
+
error("Failed to get the collectible types for transformation: " .. tostring(playerForm))
|
|
53
|
+
end
|
|
54
|
+
collectibleTypesSet:add(collectibleType)
|
|
55
|
+
local transformations = COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:get(collectibleType)
|
|
56
|
+
if transformations == nil then
|
|
57
|
+
transformations = __TS__New(Set)
|
|
58
|
+
COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:set(collectibleType, transformations)
|
|
59
|
+
end
|
|
60
|
+
transformations:add(playerForm)
|
|
61
|
+
end
|
|
62
|
+
::__continue6::
|
|
63
|
+
end
|
|
64
|
+
collectibleType = collectibleType + 1
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
function ____exports.getCollectibleTypesForTransformation(self, playerForm)
|
|
69
|
+
if TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP.size == 0 then
|
|
70
|
+
initMaps(nil)
|
|
71
|
+
end
|
|
72
|
+
local collectibleTypes = TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:get(playerForm)
|
|
73
|
+
return collectibleTypes == nil and __TS__New(Set) or copySet(nil, collectibleTypes)
|
|
74
|
+
end
|
|
14
75
|
function ____exports.getPlayerNumTransformationCollectibles(self, player, playerForm)
|
|
15
76
|
if TRANSFORMATIONS_NOT_BASED_ON_ITEMS:has(playerForm) then
|
|
16
77
|
error(("The transformation of " .. tostring(playerForm)) .. " cannot be tracked by this function.")
|
|
17
78
|
end
|
|
18
|
-
|
|
79
|
+
if TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP.size == 0 then
|
|
80
|
+
initMaps(nil)
|
|
81
|
+
end
|
|
82
|
+
local itemsForTransformation = TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:get(playerForm)
|
|
19
83
|
if itemsForTransformation == nil then
|
|
20
84
|
error(("The transformation of " .. tostring(playerForm)) .. " is not a valid value of the PlayerForm enum.")
|
|
21
85
|
end
|
|
22
86
|
local numCollectibles = 0
|
|
23
|
-
for ____, collectibleType in
|
|
87
|
+
for ____, collectibleType in __TS__Iterator(itemsForTransformation:values()) do
|
|
24
88
|
numCollectibles = numCollectibles + player:GetCollectibleNum(collectibleType)
|
|
25
89
|
end
|
|
26
90
|
return numCollectibles
|
|
27
91
|
end
|
|
28
|
-
function ____exports.getTransformationsForItem(self, collectibleType)
|
|
29
|
-
local transformations = ITEM_TO_TRANSFORMATION_MAP:get(collectibleType)
|
|
30
|
-
return transformations == nil and ({}) or arrayCopy(nil, transformations)
|
|
31
|
-
end
|
|
32
92
|
function ____exports.getTransformationName(self, transformation)
|
|
33
93
|
local defaultName = "Unknown"
|
|
34
94
|
local transformationName = TRANSFORMATION_NAME_MAP:get(transformation)
|
|
35
95
|
return transformationName == nil and defaultName or transformationName
|
|
36
96
|
end
|
|
97
|
+
function ____exports.getTransformationsForCollectibleType(self, collectibleType)
|
|
98
|
+
if COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP.size == 0 then
|
|
99
|
+
initMaps(nil)
|
|
100
|
+
end
|
|
101
|
+
local transformations = COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:get(collectibleType)
|
|
102
|
+
return transformations == nil and __TS__New(Set) or copySet(nil, transformations)
|
|
103
|
+
end
|
|
37
104
|
return ____exports
|
package/dist/functions/util.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
3
|
-
/**
|
|
4
|
-
* Using a Map constructor to copy a Map does not seem to work properly, so use this helper function
|
|
5
|
-
* instead.
|
|
6
|
-
*/
|
|
3
|
+
/** Helper function to copy a map. (You can also use a Map constructor to accomplish this task.) */
|
|
7
4
|
export declare function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V>;
|
|
8
5
|
/**
|
|
9
6
|
* Helper function to get type safety on a switch statement.
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./functions/bitwise";
|
|
|
13
13
|
export * from "./functions/cards";
|
|
14
14
|
export * from "./functions/challenges";
|
|
15
15
|
export * from "./functions/charge";
|
|
16
|
+
export * from "./functions/collectibleCacheFlag";
|
|
16
17
|
export * from "./functions/collectibles";
|
|
17
18
|
export * from "./functions/collectibleSet";
|
|
18
19
|
export * from "./functions/color";
|
|
@@ -61,7 +62,6 @@ export * from "./maps/pillEffectClassMap";
|
|
|
61
62
|
export * from "./maps/pillEffectNameMap";
|
|
62
63
|
export * from "./maps/pillEffectTypeMap";
|
|
63
64
|
export * from "./maps/roomShapeToTopLeftWallGridIndexMap";
|
|
64
|
-
export * from "./maps/transformationMaps";
|
|
65
65
|
export * from "./maps/transformationNameMap";
|
|
66
66
|
export * from "./maps/trinketNameMap";
|
|
67
67
|
export * from "./sets/cards";
|
package/dist/index.lua
CHANGED
|
@@ -116,6 +116,14 @@ do
|
|
|
116
116
|
end
|
|
117
117
|
end
|
|
118
118
|
end
|
|
119
|
+
do
|
|
120
|
+
local ____export = require("functions.collectibleCacheFlag")
|
|
121
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
122
|
+
if ____exportKey ~= "default" then
|
|
123
|
+
____exports[____exportKey] = ____exportValue
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
119
127
|
do
|
|
120
128
|
local ____export = require("functions.collectibles")
|
|
121
129
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
@@ -494,14 +502,6 @@ do
|
|
|
494
502
|
end
|
|
495
503
|
end
|
|
496
504
|
end
|
|
497
|
-
do
|
|
498
|
-
local ____export = require("maps.transformationMaps")
|
|
499
|
-
for ____exportKey, ____exportValue in pairs(____export) do
|
|
500
|
-
if ____exportKey ~= "default" then
|
|
501
|
-
____exports[____exportKey] = ____exportValue
|
|
502
|
-
end
|
|
503
|
-
end
|
|
504
|
-
end
|
|
505
505
|
do
|
|
506
506
|
local ____export = require("maps.transformationNameMap")
|
|
507
507
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
@@ -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 <=
|
|
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]
|
|
@@ -9,4 +9,5 @@ ____exports.PillEffectClass.MEDIUM = 2
|
|
|
9
9
|
____exports.PillEffectClass[____exports.PillEffectClass.MEDIUM] = "MEDIUM"
|
|
10
10
|
____exports.PillEffectClass.MAJOR = 3
|
|
11
11
|
____exports.PillEffectClass[____exports.PillEffectClass.MAJOR] = "MAJOR"
|
|
12
|
+
____exports.DEFAULT_PILL_EFFECT_CLASS = ____exports.PillEffectClass.MEDIUM
|
|
12
13
|
return ____exports
|
|
@@ -7,4 +7,5 @@ ____exports.PillEffectType.NEGATIVE = 1
|
|
|
7
7
|
____exports.PillEffectType[____exports.PillEffectType.NEGATIVE] = "NEGATIVE"
|
|
8
8
|
____exports.PillEffectType.NEUTRAL = 2
|
|
9
9
|
____exports.PillEffectType[____exports.PillEffectType.NEUTRAL] = "NEUTRAL"
|
|
10
|
+
____exports.DEFAULT_PILL_EFFECT_TYPE = ____exports.PillEffectType.NEUTRAL
|
|
10
11
|
return ____exports
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.19",
|
|
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.
|
|
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",
|