isaacscript-common 1.2.192 → 1.2.193
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/player.d.ts +5 -0
- package/dist/functions/player.lua +26 -15
- package/package.json +3 -3
|
@@ -46,6 +46,11 @@ export declare function characterCanHaveSoulHearts(character: PlayerType | int):
|
|
|
46
46
|
* Otherwise, returns false.
|
|
47
47
|
*/
|
|
48
48
|
export declare function characterGetsBlackHeartFromEternalHeart(character: PlayerType | int): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Helper function to find the active slot that the player has the corresponding collectible type
|
|
51
|
+
* in. Returns undefined if the player does not have the collectible in any active slot.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getActiveItemSlot(player: EntityPlayer, collectibleType: CollectibleType | int): ActiveSlot | undefined;
|
|
49
54
|
/**
|
|
50
55
|
* Helper function to get every player with no restrictions, by using `Game.GetNumPlayers` and
|
|
51
56
|
* `Isaac.GetPlayer`.
|
|
@@ -2,9 +2,9 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local Set = ____lualib.Set
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
4
|
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
5
|
+
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
|
|
5
6
|
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
6
7
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
7
|
-
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
|
|
8
8
|
local Map = ____lualib.Map
|
|
9
9
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
10
10
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
@@ -39,6 +39,7 @@ local ____collectibleSet = require("functions.collectibleSet")
|
|
|
39
39
|
local getCollectibleSet = ____collectibleSet.getCollectibleSet
|
|
40
40
|
local ____utils = require("functions.utils")
|
|
41
41
|
local ensureAllCases = ____utils.ensureAllCases
|
|
42
|
+
local getEnumValues = ____utils.getEnumValues
|
|
42
43
|
local ____repeat = ____utils["repeat"]
|
|
43
44
|
function ____exports.getAllPlayers(self)
|
|
44
45
|
local numPlayers = game:GetNumPlayers()
|
|
@@ -95,15 +96,15 @@ end
|
|
|
95
96
|
function getPlayerIndexCollectibleType(self, player, differentiateForgottenAndSoul)
|
|
96
97
|
local character = player:GetPlayerType()
|
|
97
98
|
repeat
|
|
98
|
-
local
|
|
99
|
-
local
|
|
100
|
-
if
|
|
99
|
+
local ____switch73 = character
|
|
100
|
+
local ____cond73 = ____switch73 == PlayerType.PLAYER_THESOUL
|
|
101
|
+
if ____cond73 then
|
|
101
102
|
do
|
|
102
103
|
return differentiateForgottenAndSoul and CollectibleType.COLLECTIBLE_SPOON_BENDER or DEFAULT_COLLECTIBLE_TYPE
|
|
103
104
|
end
|
|
104
105
|
end
|
|
105
|
-
|
|
106
|
-
if
|
|
106
|
+
____cond73 = ____cond73 or ____switch73 == PlayerType.PLAYER_LAZARUS2_B
|
|
107
|
+
if ____cond73 then
|
|
107
108
|
do
|
|
108
109
|
return CollectibleType.COLLECTIBLE_INNER_EYE
|
|
109
110
|
end
|
|
@@ -240,6 +241,16 @@ end
|
|
|
240
241
|
function ____exports.characterGetsBlackHeartFromEternalHeart(self, character)
|
|
241
242
|
return CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART:has(character)
|
|
242
243
|
end
|
|
244
|
+
function ____exports.getActiveItemSlot(self, player, collectibleType)
|
|
245
|
+
local activeSlots = getEnumValues(nil, ActiveSlot)
|
|
246
|
+
return __TS__ArrayFind(
|
|
247
|
+
activeSlots,
|
|
248
|
+
function(____, activeSlot)
|
|
249
|
+
local activeItem = player:GetActiveItem(activeSlot)
|
|
250
|
+
return activeItem == collectibleType
|
|
251
|
+
end
|
|
252
|
+
)
|
|
253
|
+
end
|
|
243
254
|
function ____exports.getAzazelBrimstoneDistance(self, playerOrTearHeight)
|
|
244
255
|
local tearHeight = tonumber(playerOrTearHeight)
|
|
245
256
|
if tearHeight == nil then
|
|
@@ -563,9 +574,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
563
574
|
itemPool:RemoveCollectible(collectibleType)
|
|
564
575
|
end
|
|
565
576
|
repeat
|
|
566
|
-
local
|
|
567
|
-
local
|
|
568
|
-
if
|
|
577
|
+
local ____switch126 = activeSlot
|
|
578
|
+
local ____cond126 = ____switch126 == ActiveSlot.SLOT_PRIMARY
|
|
579
|
+
if ____cond126 then
|
|
569
580
|
do
|
|
570
581
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
571
582
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -574,8 +585,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
574
585
|
break
|
|
575
586
|
end
|
|
576
587
|
end
|
|
577
|
-
|
|
578
|
-
if
|
|
588
|
+
____cond126 = ____cond126 or ____switch126 == ActiveSlot.SLOT_SECONDARY
|
|
589
|
+
if ____cond126 then
|
|
579
590
|
do
|
|
580
591
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
581
592
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -590,16 +601,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
590
601
|
break
|
|
591
602
|
end
|
|
592
603
|
end
|
|
593
|
-
|
|
594
|
-
if
|
|
604
|
+
____cond126 = ____cond126 or ____switch126 == ActiveSlot.SLOT_POCKET
|
|
605
|
+
if ____cond126 then
|
|
595
606
|
do
|
|
596
607
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
597
608
|
player:SetActiveCharge(charge, activeSlot)
|
|
598
609
|
break
|
|
599
610
|
end
|
|
600
611
|
end
|
|
601
|
-
|
|
602
|
-
if
|
|
612
|
+
____cond126 = ____cond126 or ____switch126 == ActiveSlot.SLOT_POCKET2
|
|
613
|
+
if ____cond126 then
|
|
603
614
|
do
|
|
604
615
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
605
616
|
break
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.193",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"dist/**/*.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^1.0.
|
|
28
|
+
"isaac-typescript-definitions": "^1.0.373",
|
|
29
29
|
"isaacscript-lint": "^1.0.93",
|
|
30
30
|
"isaacscript-tsconfig": "^1.1.8",
|
|
31
31
|
"typedoc": "^0.22.13",
|
|
32
32
|
"typescript": "4.6.2",
|
|
33
|
-
"typescript-to-lua": "^1.4.
|
|
33
|
+
"typescript-to-lua": "^1.4.2"
|
|
34
34
|
}
|
|
35
35
|
}
|