isaacscript-common 8.0.0 → 8.2.0
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/map.d.ts.map +1 -1
- package/dist/functions/map.lua +4 -17
- package/dist/functions/players.d.ts +12 -0
- package/dist/functions/players.d.ts.map +1 -1
- package/dist/functions/players.lua +52 -9
- package/dist/functions/string.d.ts +17 -0
- package/dist/functions/string.d.ts.map +1 -1
- package/dist/functions/string.lua +31 -1
- package/dist/functions/utils.d.ts +2 -2
- package/dist/functions/utils.lua +2 -2
- package/dist/index.d.ts +34 -2
- package/dist/initFeatures.d.ts.map +1 -1
- package/dist/initFeatures.lua +3 -0
- package/package.json +1 -1
- package/src/functions/map.ts +5 -11
- package/src/functions/players.ts +41 -0
- package/src/functions/string.ts +33 -0
- package/src/functions/utils.ts +2 -2
- package/src/initFeatures.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/functions/map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/functions/map.ts"],"names":[],"mappings":"AAGA,mGAAmG;AACnG,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAO1D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,GAC1B,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAgBzB;AAED,4DAA4D;AAC5D,wBAAgB,MAAM,CACpB,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,GACvD,MAAM,CAGR"}
|
package/dist/functions/map.lua
CHANGED
|
@@ -3,13 +3,11 @@ local Map = ____lualib.Map
|
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
4
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
5
5
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
6
|
-
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
7
|
-
local __TS__StringReplaceAll = ____lualib.__TS__StringReplaceAll
|
|
8
|
-
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
|
|
9
|
-
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
10
6
|
local ____exports = {}
|
|
11
7
|
local ____array = require("functions.array")
|
|
12
8
|
local sumArray = ____array.sumArray
|
|
9
|
+
local ____string = require("functions.string")
|
|
10
|
+
local getPartialMatch = ____string.getPartialMatch
|
|
13
11
|
--- Helper function to copy a map. (You can also use a Map constructor to accomplish this task.)
|
|
14
12
|
function ____exports.copyMap(self, oldMap)
|
|
15
13
|
local newMap = __TS__New(Map)
|
|
@@ -39,24 +37,13 @@ end
|
|
|
39
37
|
-- ```
|
|
40
38
|
function ____exports.getMapPartialMatch(self, searchText, map)
|
|
41
39
|
local keys = {__TS__Spread(map:keys())}
|
|
42
|
-
|
|
43
|
-
searchText = string.lower(searchText)
|
|
44
|
-
searchText = __TS__StringReplaceAll(searchText, " ", "")
|
|
45
|
-
local matchingKeys = __TS__ArrayFilter(
|
|
46
|
-
keys,
|
|
47
|
-
function(____, key) return __TS__StringStartsWith(
|
|
48
|
-
string.lower(key),
|
|
49
|
-
searchText
|
|
50
|
-
) end
|
|
51
|
-
)
|
|
52
|
-
__TS__ArraySort(matchingKeys)
|
|
53
|
-
local matchingKey = matchingKeys[1]
|
|
40
|
+
local matchingKey = getPartialMatch(nil, searchText, keys)
|
|
54
41
|
if matchingKey == nil then
|
|
55
42
|
return nil
|
|
56
43
|
end
|
|
57
44
|
local value = map:get(matchingKey)
|
|
58
45
|
if value == nil then
|
|
59
|
-
|
|
46
|
+
error("Failed to get the map value corresponding to the partial match of: " .. matchingKey)
|
|
60
47
|
end
|
|
61
48
|
return {matchingKey, value}
|
|
62
49
|
end
|
|
@@ -279,6 +279,18 @@ export declare function playerAddCollectible(player: EntityPlayer, ...collectibl
|
|
|
279
279
|
* check for. Returns true if the player has any of the supplied collectible types.
|
|
280
280
|
*/
|
|
281
281
|
export declare function playerHasCollectible(player: EntityPlayer, ...collectibleTypes: CollectibleType[]): boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Helper function to remove all of the active items from a player. This includes the Schoolbag item
|
|
284
|
+
* and any pocket actives.
|
|
285
|
+
*/
|
|
286
|
+
export declare function removeAllActiveItems(player: EntityPlayer): void;
|
|
287
|
+
/**
|
|
288
|
+
* Helper function to remove all of the held trinkets from a player.
|
|
289
|
+
*
|
|
290
|
+
* This will not remove any smelted trinkets, unless the player happens to be holding a trinket that
|
|
291
|
+
* they also have smelted. (In that case, both the held and the smelted trinket will be removed.)
|
|
292
|
+
*/
|
|
293
|
+
export declare function removeAllPlayerTrinkets(player: EntityPlayer): void;
|
|
282
294
|
/**
|
|
283
295
|
* Helper function to remove a collectible costume from a player. Use this helper function to avoid
|
|
284
296
|
* having to request the collectible from the item config.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"players.d.ts","sourceRoot":"","sources":["../../src/functions/players.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAET,eAAe,EAIf,UAAU,
|
|
1
|
+
{"version":3,"file":"players.d.ts","sourceRoot":"","sources":["../../src/functions/players.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAET,eAAe,EAIf,UAAU,EAEV,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA6BjD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,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a,UAAO,GACnB,IAAI,CAsBN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,IAAI,CAEN;AAED;;;;;;;;;GASG;AACH,wBAAgB,sDAAsD,CACpE,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,KAAK,GAClB,OAAO,CAyBT"}
|
|
@@ -18,6 +18,7 @@ local FamiliarVariant = ____isaac_2Dtypescript_2Ddefinitions.FamiliarVariant
|
|
|
18
18
|
local NullItemID = ____isaac_2Dtypescript_2Ddefinitions.NullItemID
|
|
19
19
|
local PlayerForm = ____isaac_2Dtypescript_2Ddefinitions.PlayerForm
|
|
20
20
|
local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
|
|
21
|
+
local TrinketSlot = ____isaac_2Dtypescript_2Ddefinitions.TrinketSlot
|
|
21
22
|
local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
|
|
22
23
|
local ____cachedClasses = require("core.cachedClasses")
|
|
23
24
|
local game = ____cachedClasses.game
|
|
@@ -682,6 +683,48 @@ function ____exports.playerHasCollectible(self, player, ...)
|
|
|
682
683
|
function(____, collectibleType) return player:HasCollectible(collectibleType) end
|
|
683
684
|
)
|
|
684
685
|
end
|
|
686
|
+
--- Helper function to remove all of the active items from a player. This includes the Schoolbag item
|
|
687
|
+
-- and any pocket actives.
|
|
688
|
+
function ____exports.removeAllActiveItems(self, player)
|
|
689
|
+
for ____, activeSlot in ipairs(getEnumValues(nil, ActiveSlot)) do
|
|
690
|
+
do
|
|
691
|
+
local collectibleType = player:GetActiveItem(activeSlot)
|
|
692
|
+
if collectibleType == CollectibleType.NULL then
|
|
693
|
+
goto __continue114
|
|
694
|
+
end
|
|
695
|
+
local hasCollectible
|
|
696
|
+
repeat
|
|
697
|
+
do
|
|
698
|
+
player:RemoveCollectible(collectibleType)
|
|
699
|
+
hasCollectible = player:HasCollectible(collectibleType)
|
|
700
|
+
end
|
|
701
|
+
until not hasCollectible
|
|
702
|
+
end
|
|
703
|
+
::__continue114::
|
|
704
|
+
end
|
|
705
|
+
end
|
|
706
|
+
--- Helper function to remove all of the held trinkets from a player.
|
|
707
|
+
--
|
|
708
|
+
-- This will not remove any smelted trinkets, unless the player happens to be holding a trinket that
|
|
709
|
+
-- they also have smelted. (In that case, both the held and the smelted trinket will be removed.)
|
|
710
|
+
function ____exports.removeAllPlayerTrinkets(self, player)
|
|
711
|
+
for ____, trinketSlot in ipairs(getEnumValues(nil, TrinketSlot)) do
|
|
712
|
+
do
|
|
713
|
+
local trinketType = player:GetTrinket(trinketSlot)
|
|
714
|
+
if trinketType == TrinketType.NULL then
|
|
715
|
+
goto __continue119
|
|
716
|
+
end
|
|
717
|
+
local hasTrinket
|
|
718
|
+
repeat
|
|
719
|
+
do
|
|
720
|
+
player:TryRemoveTrinket(trinketType)
|
|
721
|
+
hasTrinket = player:HasTrinket(trinketType)
|
|
722
|
+
end
|
|
723
|
+
until not hasTrinket
|
|
724
|
+
end
|
|
725
|
+
::__continue119::
|
|
726
|
+
end
|
|
727
|
+
end
|
|
685
728
|
--- Helper function to remove a collectible costume from a player. Use this helper function to avoid
|
|
686
729
|
-- having to request the collectible from the item config.
|
|
687
730
|
function ____exports.removeCollectibleCostume(self, player, collectibleType)
|
|
@@ -742,9 +785,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
742
785
|
itemPool:RemoveCollectible(collectibleType)
|
|
743
786
|
end
|
|
744
787
|
repeat
|
|
745
|
-
local
|
|
746
|
-
local
|
|
747
|
-
if
|
|
788
|
+
local ____switch132 = activeSlot
|
|
789
|
+
local ____cond132 = ____switch132 == ActiveSlot.PRIMARY
|
|
790
|
+
if ____cond132 then
|
|
748
791
|
do
|
|
749
792
|
if primaryCollectibleType ~= CollectibleType.NULL then
|
|
750
793
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -753,8 +796,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
753
796
|
break
|
|
754
797
|
end
|
|
755
798
|
end
|
|
756
|
-
|
|
757
|
-
if
|
|
799
|
+
____cond132 = ____cond132 or ____switch132 == ActiveSlot.SECONDARY
|
|
800
|
+
if ____cond132 then
|
|
758
801
|
do
|
|
759
802
|
if primaryCollectibleType ~= CollectibleType.NULL then
|
|
760
803
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -769,16 +812,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
769
812
|
break
|
|
770
813
|
end
|
|
771
814
|
end
|
|
772
|
-
|
|
773
|
-
if
|
|
815
|
+
____cond132 = ____cond132 or ____switch132 == ActiveSlot.POCKET
|
|
816
|
+
if ____cond132 then
|
|
774
817
|
do
|
|
775
818
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
776
819
|
player:SetActiveCharge(charge, activeSlot)
|
|
777
820
|
break
|
|
778
821
|
end
|
|
779
822
|
end
|
|
780
|
-
|
|
781
|
-
if
|
|
823
|
+
____cond132 = ____cond132 or ____switch132 == ActiveSlot.POCKET_SINGLE_USE
|
|
824
|
+
if ____cond132 then
|
|
782
825
|
do
|
|
783
826
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
784
827
|
break
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
export declare function capitalizeFirstLetter(string: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to get the closest value from an array of strings based on partial search text.
|
|
4
|
+
* For the purposes of this function, both search text and the array are converted to lowercase
|
|
5
|
+
* before attempting to find a match.
|
|
6
|
+
*
|
|
7
|
+
* For example:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const array = ["foo", "bar"];
|
|
11
|
+
* const searchText = "f";
|
|
12
|
+
* const match = getPartialMatch(array, searchText); // match is now equal to "foo"
|
|
13
|
+
*
|
|
14
|
+
* @returns If a match was found, returns the array element. If a match was not
|
|
15
|
+
* found, returns undefined.
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function getPartialMatch(searchText: string, array: string[]): string | undefined;
|
|
2
19
|
export declare function removeAllCharacters(string: string, character: string): string;
|
|
3
20
|
/**
|
|
4
21
|
* Helper function to remove all of the characters in a string before a given substring. Returns the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/functions/string.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAM5D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,MAAM,CAGR;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,GAAG,UAAU,EAAE,MAAM,EAAE,GACtB,MAAM,CAMR;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMjE;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOjE"}
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/functions/string.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAM5D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EAAE,GACd,MAAM,GAAG,SAAS,CAYpB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,MAAM,CAGR;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,GAAG,UAAU,EAAE,MAAM,EAAE,GACtB,MAAM,CAMR;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMjE;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOjE"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
2
3
|
local __TS__StringReplaceAll = ____lualib.__TS__StringReplaceAll
|
|
3
|
-
local __TS__StringSlice = ____lualib.__TS__StringSlice
|
|
4
4
|
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
|
|
5
|
+
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
6
|
+
local __TS__StringSlice = ____lualib.__TS__StringSlice
|
|
5
7
|
local __TS__StringEndsWith = ____lualib.__TS__StringEndsWith
|
|
6
8
|
local ____exports = {}
|
|
7
9
|
function ____exports.capitalizeFirstLetter(self, ____string)
|
|
@@ -10,6 +12,34 @@ function ____exports.capitalizeFirstLetter(self, ____string)
|
|
|
10
12
|
local restOfString = string.sub(____string, 2)
|
|
11
13
|
return capitalizedFirstLetter .. restOfString
|
|
12
14
|
end
|
|
15
|
+
--- Helper function to get the closest value from an array of strings based on partial search text.
|
|
16
|
+
-- For the purposes of this function, both search text and the array are converted to lowercase
|
|
17
|
+
-- before attempting to find a match.
|
|
18
|
+
--
|
|
19
|
+
-- For example:
|
|
20
|
+
--
|
|
21
|
+
-- ```ts
|
|
22
|
+
-- const array = ["foo", "bar"];
|
|
23
|
+
-- const searchText = "f";
|
|
24
|
+
-- const match = getPartialMatch(array, searchText); // match is now equal to "foo"
|
|
25
|
+
--
|
|
26
|
+
-- @returns If a match was found, returns the array element. If a match was not
|
|
27
|
+
-- found, returns undefined.
|
|
28
|
+
-- ```
|
|
29
|
+
function ____exports.getPartialMatch(self, searchText, array)
|
|
30
|
+
__TS__ArraySort(array)
|
|
31
|
+
searchText = string.lower(searchText)
|
|
32
|
+
searchText = __TS__StringReplaceAll(searchText, " ", "")
|
|
33
|
+
local matchingElements = __TS__ArrayFilter(
|
|
34
|
+
array,
|
|
35
|
+
function(____, element) return __TS__StringStartsWith(
|
|
36
|
+
string.lower(element),
|
|
37
|
+
searchText
|
|
38
|
+
) end
|
|
39
|
+
)
|
|
40
|
+
__TS__ArraySort(matchingElements)
|
|
41
|
+
return matchingElements[1]
|
|
42
|
+
end
|
|
13
43
|
function ____exports.removeAllCharacters(self, ____string, character)
|
|
14
44
|
return __TS__StringReplaceAll(____string, character, "")
|
|
15
45
|
end
|
|
@@ -80,13 +80,13 @@ export declare function repeat(n: int, func: (i: int) => void): void;
|
|
|
80
80
|
/**
|
|
81
81
|
* Helper function to signify that the enclosing code block is not yet complete. Using this function
|
|
82
82
|
* is similar to writing a "TODO" comment, but it has the benefit of preventing ESLint errors due to
|
|
83
|
-
* early returns.
|
|
83
|
+
* unused variables or early returns.
|
|
84
84
|
*
|
|
85
85
|
* When you see this function, it simply means that the programmer intends to add in more code to
|
|
86
86
|
* this spot later.
|
|
87
87
|
*
|
|
88
88
|
* This function is variadic, meaning that you can pass as many arguments as you want. (This is
|
|
89
|
-
* useful as a means to prevent
|
|
89
|
+
* useful as a means to prevent unused variables.)
|
|
90
90
|
*
|
|
91
91
|
* This function does not actually do anything. (It is an "empty" function.)
|
|
92
92
|
*/
|
package/dist/functions/utils.lua
CHANGED
|
@@ -153,13 +153,13 @@ ____exports["repeat"] = function(self, n, func)
|
|
|
153
153
|
end
|
|
154
154
|
--- Helper function to signify that the enclosing code block is not yet complete. Using this function
|
|
155
155
|
-- is similar to writing a "TODO" comment, but it has the benefit of preventing ESLint errors due to
|
|
156
|
-
-- early returns.
|
|
156
|
+
-- unused variables or early returns.
|
|
157
157
|
--
|
|
158
158
|
-- When you see this function, it simply means that the programmer intends to add in more code to
|
|
159
159
|
-- this spot later.
|
|
160
160
|
--
|
|
161
161
|
-- This function is variadic, meaning that you can pass as many arguments as you want. (This is
|
|
162
|
-
-- useful as a means to prevent
|
|
162
|
+
-- useful as a means to prevent unused variables.)
|
|
163
163
|
--
|
|
164
164
|
-- This function does not actually do anything. (It is an "empty" function.)
|
|
165
165
|
function ____exports.todo(self, ...)
|
package/dist/index.d.ts
CHANGED
|
@@ -3790,6 +3790,24 @@ export declare function getOppositeDoorSlot(doorSlot: DoorSlot): DoorSlot | unde
|
|
|
3790
3790
|
*/
|
|
3791
3791
|
export declare function getOtherPlayers(player: EntityPlayer): EntityPlayer[];
|
|
3792
3792
|
|
|
3793
|
+
/**
|
|
3794
|
+
* Helper function to get the closest value from an array of strings based on partial search text.
|
|
3795
|
+
* For the purposes of this function, both search text and the array are converted to lowercase
|
|
3796
|
+
* before attempting to find a match.
|
|
3797
|
+
*
|
|
3798
|
+
* For example:
|
|
3799
|
+
*
|
|
3800
|
+
* ```ts
|
|
3801
|
+
* const array = ["foo", "bar"];
|
|
3802
|
+
* const searchText = "f";
|
|
3803
|
+
* const match = getPartialMatch(array, searchText); // match is now equal to "foo"
|
|
3804
|
+
*
|
|
3805
|
+
* @returns If a match was found, returns the array element. If a match was not
|
|
3806
|
+
* found, returns undefined.
|
|
3807
|
+
* ```
|
|
3808
|
+
*/
|
|
3809
|
+
export declare function getPartialMatch(searchText: string, array: string[]): string | undefined;
|
|
3810
|
+
|
|
3793
3811
|
/**
|
|
3794
3812
|
* Helper function to get the associated pill effect after PHD is acquired. If a pill effect is not
|
|
3795
3813
|
* altered by PHD, then the same pill effect will be returned.
|
|
@@ -8968,6 +8986,12 @@ export declare function registerHotkey(keyboardOrFunc: Keyboard | (() => Keyboar
|
|
|
8968
8986
|
*/
|
|
8969
8987
|
export declare function reloadRoom(): void;
|
|
8970
8988
|
|
|
8989
|
+
/**
|
|
8990
|
+
* Helper function to remove all of the active items from a player. This includes the Schoolbag item
|
|
8991
|
+
* and any pocket actives.
|
|
8992
|
+
*/
|
|
8993
|
+
export declare function removeAllActiveItems(player: EntityPlayer): void;
|
|
8994
|
+
|
|
8971
8995
|
/**
|
|
8972
8996
|
* Helper function to remove all of the batteries in the room.
|
|
8973
8997
|
*
|
|
@@ -9215,6 +9239,14 @@ export declare function removeAllPits(pitVariant?: PitVariant, updateRoom?: bool
|
|
|
9215
9239
|
|
|
9216
9240
|
export declare function removeAllPlayerHealth(player: EntityPlayer): void;
|
|
9217
9241
|
|
|
9242
|
+
/**
|
|
9243
|
+
* Helper function to remove all of the held trinkets from a player.
|
|
9244
|
+
*
|
|
9245
|
+
* This will not remove any smelted trinkets, unless the player happens to be holding a trinket that
|
|
9246
|
+
* they also have smelted. (In that case, both the held and the smelted trinket will be removed.)
|
|
9247
|
+
*/
|
|
9248
|
+
export declare function removeAllPlayerTrinkets(player: EntityPlayer): void;
|
|
9249
|
+
|
|
9218
9250
|
/**
|
|
9219
9251
|
* Helper function to remove all of the `GridEntityPoop` in the room.
|
|
9220
9252
|
*
|
|
@@ -11198,13 +11230,13 @@ export declare function texelEquals(sprite1: Sprite, sprite2: Sprite, position:
|
|
|
11198
11230
|
/**
|
|
11199
11231
|
* Helper function to signify that the enclosing code block is not yet complete. Using this function
|
|
11200
11232
|
* is similar to writing a "TODO" comment, but it has the benefit of preventing ESLint errors due to
|
|
11201
|
-
* early returns.
|
|
11233
|
+
* unused variables or early returns.
|
|
11202
11234
|
*
|
|
11203
11235
|
* When you see this function, it simply means that the programmer intends to add in more code to
|
|
11204
11236
|
* this spot later.
|
|
11205
11237
|
*
|
|
11206
11238
|
* This function is variadic, meaning that you can pass as many arguments as you want. (This is
|
|
11207
|
-
* useful as a means to prevent
|
|
11239
|
+
* useful as a means to prevent unused variables.)
|
|
11208
11240
|
*
|
|
11209
11241
|
* This function does not actually do anything. (It is an "empty" function.)
|
|
11210
11242
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initFeatures.d.ts","sourceRoot":"","sources":["../src/initFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"initFeatures.d.ts","sourceRoot":"","sources":["../src/initFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AA+BpD,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAGnD"}
|
package/dist/initFeatures.lua
CHANGED
|
@@ -24,6 +24,8 @@ local ____fadeInRemover = require("features.fadeInRemover")
|
|
|
24
24
|
local fadeInRemoverInit = ____fadeInRemover.fadeInRemoverInit
|
|
25
25
|
local ____fastReset = require("features.fastReset")
|
|
26
26
|
local fastResetInit = ____fastReset.fastResetInit
|
|
27
|
+
local ____firstLast = require("features.firstLast")
|
|
28
|
+
local firstLastInit = ____firstLast.firstLastInit
|
|
27
29
|
local ____forgottenSwitch = require("features.forgottenSwitch")
|
|
28
30
|
local forgottenSwitchInit = ____forgottenSwitch.forgottenSwitchInit
|
|
29
31
|
local ____pause = require("features.pause")
|
|
@@ -71,6 +73,7 @@ function initFeaturesMinor(self, mod)
|
|
|
71
73
|
disableInputsInit(nil, mod)
|
|
72
74
|
fadeInRemoverInit(nil, mod)
|
|
73
75
|
fastResetInit(nil, mod)
|
|
76
|
+
firstLastInit(nil, mod)
|
|
74
77
|
forgottenSwitchInit(nil, mod)
|
|
75
78
|
collectibleItemPoolTypeInit(nil, mod)
|
|
76
79
|
pauseInit(nil, mod)
|
package/package.json
CHANGED
package/src/functions/map.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { sumArray } from "./array";
|
|
2
|
+
import { getPartialMatch } from "./string";
|
|
2
3
|
|
|
3
4
|
/** Helper function to copy a map. (You can also use a Map constructor to accomplish this task.) */
|
|
4
5
|
export function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V> {
|
|
@@ -34,24 +35,17 @@ export function getMapPartialMatch<T>(
|
|
|
34
35
|
map: ReadonlyMap<string, T>,
|
|
35
36
|
): [string, T] | undefined {
|
|
36
37
|
const keys = [...map.keys()];
|
|
37
|
-
keys.sort();
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
searchText = searchText.replaceAll(" ", "");
|
|
41
|
-
|
|
42
|
-
const matchingKeys = keys.filter((key) =>
|
|
43
|
-
key.toLowerCase().startsWith(searchText),
|
|
44
|
-
);
|
|
45
|
-
matchingKeys.sort();
|
|
46
|
-
|
|
47
|
-
const matchingKey = matchingKeys[0];
|
|
39
|
+
const matchingKey = getPartialMatch(searchText, keys);
|
|
48
40
|
if (matchingKey === undefined) {
|
|
49
41
|
return undefined;
|
|
50
42
|
}
|
|
51
43
|
|
|
52
44
|
const value = map.get(matchingKey);
|
|
53
45
|
if (value === undefined) {
|
|
54
|
-
|
|
46
|
+
error(
|
|
47
|
+
`Failed to get the map value corresponding to the partial match of: ${matchingKey}`,
|
|
48
|
+
);
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
return [matchingKey, value];
|
package/src/functions/players.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
NullItemID,
|
|
8
8
|
PlayerForm,
|
|
9
9
|
PlayerType,
|
|
10
|
+
TrinketSlot,
|
|
10
11
|
TrinketType,
|
|
11
12
|
} from "isaac-typescript-definitions";
|
|
12
13
|
import { game, itemConfig } from "../core/cachedClasses";
|
|
@@ -882,6 +883,46 @@ export function playerHasCollectible(
|
|
|
882
883
|
);
|
|
883
884
|
}
|
|
884
885
|
|
|
886
|
+
/**
|
|
887
|
+
* Helper function to remove all of the active items from a player. This includes the Schoolbag item
|
|
888
|
+
* and any pocket actives.
|
|
889
|
+
*/
|
|
890
|
+
export function removeAllActiveItems(player: EntityPlayer): void {
|
|
891
|
+
for (const activeSlot of getEnumValues(ActiveSlot)) {
|
|
892
|
+
const collectibleType = player.GetActiveItem(activeSlot);
|
|
893
|
+
if (collectibleType === CollectibleType.NULL) {
|
|
894
|
+
continue;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
let hasCollectible: boolean;
|
|
898
|
+
do {
|
|
899
|
+
player.RemoveCollectible(collectibleType);
|
|
900
|
+
hasCollectible = player.HasCollectible(collectibleType);
|
|
901
|
+
} while (hasCollectible);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Helper function to remove all of the held trinkets from a player.
|
|
907
|
+
*
|
|
908
|
+
* This will not remove any smelted trinkets, unless the player happens to be holding a trinket that
|
|
909
|
+
* they also have smelted. (In that case, both the held and the smelted trinket will be removed.)
|
|
910
|
+
*/
|
|
911
|
+
export function removeAllPlayerTrinkets(player: EntityPlayer): void {
|
|
912
|
+
for (const trinketSlot of getEnumValues(TrinketSlot)) {
|
|
913
|
+
const trinketType = player.GetTrinket(trinketSlot);
|
|
914
|
+
if (trinketType === TrinketType.NULL) {
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
let hasTrinket: boolean;
|
|
919
|
+
do {
|
|
920
|
+
player.TryRemoveTrinket(trinketType);
|
|
921
|
+
hasTrinket = player.HasTrinket(trinketType);
|
|
922
|
+
} while (hasTrinket);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
885
926
|
/**
|
|
886
927
|
* Helper function to remove a collectible costume from a player. Use this helper function to avoid
|
|
887
928
|
* having to request the collectible from the item config.
|
package/src/functions/string.ts
CHANGED
|
@@ -6,6 +6,39 @@ export function capitalizeFirstLetter(string: string): string {
|
|
|
6
6
|
return `${capitalizedFirstLetter}${restOfString}`;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Helper function to get the closest value from an array of strings based on partial search text.
|
|
11
|
+
* For the purposes of this function, both search text and the array are converted to lowercase
|
|
12
|
+
* before attempting to find a match.
|
|
13
|
+
*
|
|
14
|
+
* For example:
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* const array = ["foo", "bar"];
|
|
18
|
+
* const searchText = "f";
|
|
19
|
+
* const match = getPartialMatch(array, searchText); // match is now equal to "foo"
|
|
20
|
+
*
|
|
21
|
+
* @returns If a match was found, returns the array element. If a match was not
|
|
22
|
+
* found, returns undefined.
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function getPartialMatch(
|
|
26
|
+
searchText: string,
|
|
27
|
+
array: string[],
|
|
28
|
+
): string | undefined {
|
|
29
|
+
array.sort();
|
|
30
|
+
|
|
31
|
+
searchText = searchText.toLowerCase();
|
|
32
|
+
searchText = searchText.replaceAll(" ", "");
|
|
33
|
+
|
|
34
|
+
const matchingElements = array.filter((element) =>
|
|
35
|
+
element.toLowerCase().startsWith(searchText),
|
|
36
|
+
);
|
|
37
|
+
matchingElements.sort();
|
|
38
|
+
|
|
39
|
+
return matchingElements[0];
|
|
40
|
+
}
|
|
41
|
+
|
|
9
42
|
export function removeAllCharacters(string: string, character: string): string {
|
|
10
43
|
return string.replaceAll(character, "");
|
|
11
44
|
}
|
package/src/functions/utils.ts
CHANGED
|
@@ -182,13 +182,13 @@ export function repeat(n: int, func: (i: int) => void): void {
|
|
|
182
182
|
/**
|
|
183
183
|
* Helper function to signify that the enclosing code block is not yet complete. Using this function
|
|
184
184
|
* is similar to writing a "TODO" comment, but it has the benefit of preventing ESLint errors due to
|
|
185
|
-
* early returns.
|
|
185
|
+
* unused variables or early returns.
|
|
186
186
|
*
|
|
187
187
|
* When you see this function, it simply means that the programmer intends to add in more code to
|
|
188
188
|
* this spot later.
|
|
189
189
|
*
|
|
190
190
|
* This function is variadic, meaning that you can pass as many arguments as you want. (This is
|
|
191
|
-
* useful as a means to prevent
|
|
191
|
+
* useful as a means to prevent unused variables.)
|
|
192
192
|
*
|
|
193
193
|
* This function does not actually do anything. (It is an "empty" function.)
|
|
194
194
|
*/
|
package/src/initFeatures.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { disableAllSoundInit } from "./features/disableAllSound";
|
|
|
11
11
|
import { disableInputsInit } from "./features/disableInputs";
|
|
12
12
|
import { fadeInRemoverInit } from "./features/fadeInRemover";
|
|
13
13
|
import { fastResetInit } from "./features/fastReset";
|
|
14
|
+
import { firstLastInit } from "./features/firstLast";
|
|
14
15
|
import { forgottenSwitchInit } from "./features/forgottenSwitch";
|
|
15
16
|
import { pauseInit } from "./features/pause";
|
|
16
17
|
import { persistentEntitiesInit } from "./features/persistentEntities";
|
|
@@ -49,6 +50,7 @@ function initFeaturesMinor(mod: ModUpgraded) {
|
|
|
49
50
|
disableInputsInit(mod);
|
|
50
51
|
fadeInRemoverInit(mod);
|
|
51
52
|
fastResetInit(mod);
|
|
53
|
+
firstLastInit(mod);
|
|
52
54
|
forgottenSwitchInit(mod);
|
|
53
55
|
collectibleItemPoolTypeInit(mod);
|
|
54
56
|
pauseInit(mod);
|