isaacscript-common 1.2.191 → 1.2.194
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.
|
@@ -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
|
|
@@ -21,3 +21,8 @@ export declare function getPocketItems(player: EntityPlayer): PocketItemDescript
|
|
|
21
21
|
* items. (Only Tainted Forgotten can pick up items.)
|
|
22
22
|
*/
|
|
23
23
|
export declare function hasOpenPocketItemSlot(player: EntityPlayer): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Helper function to determine whether or not the player's "active" pocket item slot is set to
|
|
26
|
+
* their pocket active item.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isFirstSlotPocketActiveItem(player: EntityPlayer): boolean;
|
|
@@ -60,4 +60,9 @@ function ____exports.hasOpenPocketItemSlot(self, player)
|
|
|
60
60
|
function(____, pocketItem) return pocketItem.type == PocketItemType.EMPTY end
|
|
61
61
|
)
|
|
62
62
|
end
|
|
63
|
+
function ____exports.isFirstSlotPocketActiveItem(self, player)
|
|
64
|
+
local pocketItems = ____exports.getPocketItems(nil, player)
|
|
65
|
+
local firstPocketItem = pocketItems[1]
|
|
66
|
+
return firstPocketItem.type == PocketItemType.ACTIVE_ITEM
|
|
67
|
+
end
|
|
63
68
|
return ____exports
|
|
@@ -36,6 +36,21 @@
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export declare const ensureAllCases: (obj: never) => never;
|
|
39
|
+
/**
|
|
40
|
+
* TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
|
|
41
|
+
* when you iterate over them, you will get both the names of the enums and the values of the enums,
|
|
42
|
+
* in a random order. If all you need are the keys of an enum, use this helper function.
|
|
43
|
+
*
|
|
44
|
+
* This function will return the enum keys in a sorted order, which may not necessarily be the same
|
|
45
|
+
* order as which they were declared in.
|
|
46
|
+
*
|
|
47
|
+
* This function will work properly for both number enums and string enums. (Reverse mappings are
|
|
48
|
+
* not created for string enums.)
|
|
49
|
+
*
|
|
50
|
+
* For a more in depth explanation, see:
|
|
51
|
+
* https://isaacscript.github.io/docs/gotchas#iterating-over-enums
|
|
52
|
+
*/
|
|
53
|
+
export declare function getEnumKeys<T>(transpiledEnum: T): string[];
|
|
39
54
|
/**
|
|
40
55
|
* TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
|
|
41
56
|
* when you iterate over them, you will get both the names of the enums and the values of the enums,
|
package/dist/functions/utils.lua
CHANGED
|
@@ -6,6 +6,16 @@ local __TS__StringSubstr = ____lualib.__TS__StringSubstr
|
|
|
6
6
|
local ____exports = {}
|
|
7
7
|
local HEX_STRING_LENGTH = 6
|
|
8
8
|
____exports.ensureAllCases = function(____, obj) return obj end
|
|
9
|
+
function ____exports.getEnumKeys(self, transpiledEnum)
|
|
10
|
+
local enumKeys = {}
|
|
11
|
+
for key in pairs(transpiledEnum) do
|
|
12
|
+
if type(key) == "string" then
|
|
13
|
+
__TS__ArrayPush(enumKeys, key)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
__TS__ArraySort(enumKeys)
|
|
17
|
+
return enumKeys
|
|
18
|
+
end
|
|
9
19
|
function ____exports.getEnumValues(self, transpiledEnum)
|
|
10
20
|
local enumValues = {}
|
|
11
21
|
for key, value in pairs(transpiledEnum) do
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.194",
|
|
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
|
}
|