isaacscript-common 1.2.8 → 1.2.9
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/collectibleSet.lua +2 -2
- package/dist/functions/globals.lua +3 -2
- package/dist/functions/player.d.ts +7 -0
- package/dist/functions/player.lua +26 -13
- package/dist/functions/set.d.ts +18 -0
- package/dist/functions/set.lua +32 -0
- package/dist/functions/trinketSet.lua +2 -2
- package/dist/functions/util.d.ts +2 -18
- package/dist/functions/util.lua +9 -27
- package/dist/index.d.ts +1 -0
- package/dist/index.lua +8 -0
- package/package.json +1 -1
|
@@ -5,8 +5,8 @@ local __TS__New = ____lualib.__TS__New
|
|
|
5
5
|
local ____exports = {}
|
|
6
6
|
local ____collectibles = require("functions.collectibles")
|
|
7
7
|
local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
|
|
8
|
-
local
|
|
9
|
-
local copySet =
|
|
8
|
+
local ____set = require("functions.set")
|
|
9
|
+
local copySet = ____set.copySet
|
|
10
10
|
local COLLECTIBLE_SET = __TS__New(Set)
|
|
11
11
|
local function initCollectibleSet(self)
|
|
12
12
|
local itemConfig = Isaac.GetItemConfig()
|
|
@@ -8,9 +8,10 @@ local ____exports = {}
|
|
|
8
8
|
local twoDimensionalSort
|
|
9
9
|
local ____log = require("functions.log")
|
|
10
10
|
local log = ____log.log
|
|
11
|
+
local ____set = require("functions.set")
|
|
12
|
+
local addSetsToSet = ____set.addSetsToSet
|
|
13
|
+
local copySet = ____set.copySet
|
|
11
14
|
local ____util = require("functions.util")
|
|
12
|
-
local addSetsToSet = ____util.addSetsToSet
|
|
13
|
-
local copySet = ____util.copySet
|
|
14
15
|
local isLuaDebugEnabled = ____util.isLuaDebugEnabled
|
|
15
16
|
function twoDimensionalSort(self, a, b)
|
|
16
17
|
if a[1] == b[1] then
|
|
@@ -131,6 +131,11 @@ export declare function getPlayerIndexVanilla(playerToFind: EntityPlayer): int |
|
|
|
131
131
|
* Does not account for Broken Hearts; use the `getPlayerAvailableHeartSlots()` function for that.
|
|
132
132
|
*/
|
|
133
133
|
export declare function getPlayerMaxHeartContainers(player: EntityPlayer): int;
|
|
134
|
+
/**
|
|
135
|
+
* Helper function to get the name of the player. Use this instead of the `EntityPlayer.GetName`
|
|
136
|
+
* method if you want the name to include the "Tainted" prefix.
|
|
137
|
+
*/
|
|
138
|
+
export declare function getPlayerName(player: EntityPlayer): string;
|
|
134
139
|
/**
|
|
135
140
|
* Returns the combined value of all of the player's red hearts, soul/black hearts, and bone hearts,
|
|
136
141
|
* minus the value of the player's rotten hearts.
|
|
@@ -207,6 +212,8 @@ export declare function isLost(player: EntityPlayer): boolean;
|
|
|
207
212
|
* Deals. (e.g. The Lost, Tainted Lost, etc.)
|
|
208
213
|
*/
|
|
209
214
|
export declare function canTakeFreeDevilDeals(player: EntityPlayer): boolean;
|
|
215
|
+
/** Helper function for detecting if a player is one of the Tainted characters. */
|
|
216
|
+
export declare function isTainted(player: EntityPlayer): boolean;
|
|
210
217
|
/** Helper function for detecting when a player is Tainted Lazarus or Dead Tainted Lazarus. */
|
|
211
218
|
export declare function isTaintedLazarus(player: EntityPlayer): boolean;
|
|
212
219
|
export declare function removeCollectibleCostume(player: EntityPlayer, collectibleType: CollectibleType | int): void;
|
|
@@ -30,6 +30,7 @@ local ____collectibleSet = require("functions.collectibleSet")
|
|
|
30
30
|
local getCollectibleSet = ____collectibleSet.getCollectibleSet
|
|
31
31
|
local ____util = require("functions.util")
|
|
32
32
|
local ensureAllCases = ____util.ensureAllCases
|
|
33
|
+
local trimPrefix = ____util.trimPrefix
|
|
33
34
|
function ____exports.getCharacterMaxHeartContainers(self, character)
|
|
34
35
|
if character == PlayerType.PLAYER_KEEPER then
|
|
35
36
|
return 3
|
|
@@ -78,18 +79,18 @@ function ____exports.getPlayers(self, performExclusions)
|
|
|
78
79
|
do
|
|
79
80
|
local player = Isaac.GetPlayer(i)
|
|
80
81
|
if player == nil then
|
|
81
|
-
goto
|
|
82
|
+
goto __continue72
|
|
82
83
|
end
|
|
83
84
|
if ____exports.isChildPlayer(nil, player) then
|
|
84
|
-
goto
|
|
85
|
+
goto __continue72
|
|
85
86
|
end
|
|
86
87
|
local character = player:GetPlayerType()
|
|
87
88
|
if performExclusions and EXCLUDED_CHARACTERS:has(character) then
|
|
88
|
-
goto
|
|
89
|
+
goto __continue72
|
|
89
90
|
end
|
|
90
91
|
__TS__ArrayPush(players, player)
|
|
91
92
|
end
|
|
92
|
-
::
|
|
93
|
+
::__continue72::
|
|
93
94
|
i = i + 1
|
|
94
95
|
end
|
|
95
96
|
end
|
|
@@ -98,6 +99,10 @@ end
|
|
|
98
99
|
function ____exports.isChildPlayer(self, player)
|
|
99
100
|
return player.Parent ~= nil
|
|
100
101
|
end
|
|
102
|
+
function ____exports.isTainted(self, player)
|
|
103
|
+
local character = player:GetPlayerType()
|
|
104
|
+
return character >= PlayerType.PLAYER_ISAAC_B
|
|
105
|
+
end
|
|
101
106
|
EXCLUDED_CHARACTERS = __TS__New(Set, {PlayerType.PLAYER_ESAU, PlayerType.PLAYER_THESOUL_B})
|
|
102
107
|
function ____exports.addCollectibleCostume(self, player, collectibleType)
|
|
103
108
|
local itemConfig = Isaac.GetItemConfig()
|
|
@@ -307,6 +312,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
|
|
|
307
312
|
end
|
|
308
313
|
return nil
|
|
309
314
|
end
|
|
315
|
+
function ____exports.getPlayerName(self, player)
|
|
316
|
+
local name = player:GetName()
|
|
317
|
+
if not ____exports.isTainted(nil, player) then
|
|
318
|
+
return name
|
|
319
|
+
end
|
|
320
|
+
local baseName = trimPrefix(nil, name, "The ")
|
|
321
|
+
return "Tainted " .. baseName
|
|
322
|
+
end
|
|
310
323
|
function ____exports.getPlayerNumHitsRemaining(self, player)
|
|
311
324
|
local hearts = player:GetHearts()
|
|
312
325
|
local soulHearts = player:GetSoulHearts()
|
|
@@ -463,9 +476,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
463
476
|
itemPool:RemoveCollectible(collectibleType)
|
|
464
477
|
end
|
|
465
478
|
repeat
|
|
466
|
-
local
|
|
467
|
-
local
|
|
468
|
-
if
|
|
479
|
+
local ____switch112 = activeSlot
|
|
480
|
+
local ____cond112 = ____switch112 == ActiveSlot.SLOT_PRIMARY
|
|
481
|
+
if ____cond112 then
|
|
469
482
|
do
|
|
470
483
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
471
484
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -474,8 +487,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
474
487
|
break
|
|
475
488
|
end
|
|
476
489
|
end
|
|
477
|
-
|
|
478
|
-
if
|
|
490
|
+
____cond112 = ____cond112 or ____switch112 == ActiveSlot.SLOT_SECONDARY
|
|
491
|
+
if ____cond112 then
|
|
479
492
|
do
|
|
480
493
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
481
494
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -490,16 +503,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
490
503
|
break
|
|
491
504
|
end
|
|
492
505
|
end
|
|
493
|
-
|
|
494
|
-
if
|
|
506
|
+
____cond112 = ____cond112 or ____switch112 == ActiveSlot.SLOT_POCKET
|
|
507
|
+
if ____cond112 then
|
|
495
508
|
do
|
|
496
509
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
497
510
|
player:SetActiveCharge(charge, activeSlot)
|
|
498
511
|
break
|
|
499
512
|
end
|
|
500
513
|
end
|
|
501
|
-
|
|
502
|
-
if
|
|
514
|
+
____cond112 = ____cond112 or ____switch112 == ActiveSlot.SLOT_POCKET2
|
|
515
|
+
if ____cond112 then
|
|
503
516
|
do
|
|
504
517
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
505
518
|
break
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to add all of the contents of one set to another set. The first set passed will
|
|
3
|
+
* be modified in place.
|
|
4
|
+
*
|
|
5
|
+
* This function is variadic, meaning that you can specify N sets to add to the first set.
|
|
6
|
+
*/
|
|
7
|
+
export declare function addSetsToSet<T>(mainSet: Set<T>, ...setsToAdd: Array<Set<T>>): void;
|
|
8
|
+
/**
|
|
9
|
+
* Using a Set constructor to copy a Set does not seem to work properly, so use this helper function
|
|
10
|
+
* instead.
|
|
11
|
+
*/
|
|
12
|
+
export declare function copySet<T>(oldSet: Set<T>): Set<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Helper function to create a new set that is the composition of two or more sets.
|
|
15
|
+
*
|
|
16
|
+
* This function is variadic, meaning that you can specify N sets.
|
|
17
|
+
*/
|
|
18
|
+
export declare function combineSets<T>(...sets: Array<Set<T>>): Set<T>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____lualib = require("lualib_bundle")
|
|
3
|
+
local Set = ____lualib.Set
|
|
4
|
+
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
5
|
+
local __TS__New = ____lualib.__TS__New
|
|
6
|
+
local ____exports = {}
|
|
7
|
+
function ____exports.addSetsToSet(self, mainSet, ...)
|
|
8
|
+
local setsToAdd = {...}
|
|
9
|
+
for ____, set in ipairs(setsToAdd) do
|
|
10
|
+
for ____, value in __TS__Iterator(set:values()) do
|
|
11
|
+
mainSet:add(value)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
function ____exports.copySet(self, oldSet)
|
|
16
|
+
local newSet = __TS__New(Set)
|
|
17
|
+
for ____, value in __TS__Iterator(oldSet:values()) do
|
|
18
|
+
newSet:add(value)
|
|
19
|
+
end
|
|
20
|
+
return newSet
|
|
21
|
+
end
|
|
22
|
+
function ____exports.combineSets(self, ...)
|
|
23
|
+
local sets = {...}
|
|
24
|
+
local newSet = __TS__New(Set)
|
|
25
|
+
for ____, set in ipairs(sets) do
|
|
26
|
+
for ____, value in __TS__Iterator(set:values()) do
|
|
27
|
+
newSet:add(value)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
return newSet
|
|
31
|
+
end
|
|
32
|
+
return ____exports
|
|
@@ -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 ____exports = {}
|
|
6
|
+
local ____set = require("functions.set")
|
|
7
|
+
local copySet = ____set.copySet
|
|
6
8
|
local ____trinkets = require("functions.trinkets")
|
|
7
9
|
local getMaxTrinketID = ____trinkets.getMaxTrinketID
|
|
8
|
-
local ____util = require("functions.util")
|
|
9
|
-
local copySet = ____util.copySet
|
|
10
10
|
local TRINKET_SET = __TS__New(Set)
|
|
11
11
|
local function initTrinketSet(self)
|
|
12
12
|
local itemConfig = Isaac.GetItemConfig()
|
package/dist/functions/util.d.ts
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
3
|
-
/**
|
|
4
|
-
* Helper function to add all of the contents of one set to another set. The first set passed will
|
|
5
|
-
* be modified in place.
|
|
6
|
-
*
|
|
7
|
-
* This function is variadic, meaning that you can specify N sets to add to the first set.
|
|
8
|
-
*/
|
|
9
|
-
export declare function addSetsToSet<T>(mainSet: Set<T>, ...setsToAdd: Array<Set<T>>): void;
|
|
10
3
|
/**
|
|
11
4
|
* Using a Map constructor to copy a Map does not seem to work properly, so use this helper function
|
|
12
5
|
* instead.
|
|
13
6
|
*/
|
|
14
7
|
export declare function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V>;
|
|
15
|
-
/**
|
|
16
|
-
* Using a Set constructor to copy a Set does not seem to work properly, so use this helper function
|
|
17
|
-
* instead.
|
|
18
|
-
*/
|
|
19
|
-
export declare function copySet<T>(oldSet: Set<T>): Set<T>;
|
|
20
|
-
/**
|
|
21
|
-
* Helper function to create a new set that is the composition of two or more sets.
|
|
22
|
-
*
|
|
23
|
-
* This function is variadic, meaning that you can specify N sets.
|
|
24
|
-
*/
|
|
25
|
-
export declare function combineSets<T>(...sets: Array<Set<T>>): Set<T>;
|
|
26
8
|
/**
|
|
27
9
|
* Helper function to get type safety on a switch statement.
|
|
28
10
|
* Very useful to be future-safe against people adding values to a type or an enum.
|
|
@@ -103,3 +85,5 @@ export declare function printConsole(msg: string): void;
|
|
|
103
85
|
* `clear` method does not exist. Use this helper function as a drop-in replacement for this.
|
|
104
86
|
*/
|
|
105
87
|
export declare function tableClear(table: LuaTable): void;
|
|
88
|
+
/** Helper function to trim a prefix from a string, if it exists. Returns the trimmed string. */
|
|
89
|
+
export declare function trimPrefix(string: string, prefix: string): string;
|
package/dist/functions/util.lua
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
|
-
local Set = ____lualib.Set
|
|
4
|
-
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
5
3
|
local Map = ____lualib.Map
|
|
6
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
|
+
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
7
6
|
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
8
7
|
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
9
8
|
local __TS__StringReplace = ____lualib.__TS__StringReplace
|
|
10
9
|
local __TS__StringSubstr = ____lualib.__TS__StringSubstr
|
|
10
|
+
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
|
|
11
|
+
local __TS__StringSlice = ____lualib.__TS__StringSlice
|
|
11
12
|
local ____exports = {}
|
|
12
13
|
local HEX_STRING_LENGTH = 6
|
|
13
|
-
function ____exports.addSetsToSet(self, mainSet, ...)
|
|
14
|
-
local setsToAdd = {...}
|
|
15
|
-
for ____, set in ipairs(setsToAdd) do
|
|
16
|
-
for ____, value in __TS__Iterator(set:values()) do
|
|
17
|
-
mainSet:add(value)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
14
|
function ____exports.copyMap(self, oldMap)
|
|
22
15
|
local newMap = __TS__New(Map)
|
|
23
16
|
for ____, ____value in __TS__Iterator(oldMap:entries()) do
|
|
@@ -27,23 +20,6 @@ function ____exports.copyMap(self, oldMap)
|
|
|
27
20
|
end
|
|
28
21
|
return newMap
|
|
29
22
|
end
|
|
30
|
-
function ____exports.copySet(self, oldSet)
|
|
31
|
-
local newSet = __TS__New(Set)
|
|
32
|
-
for ____, value in __TS__Iterator(oldSet:values()) do
|
|
33
|
-
newSet:add(value)
|
|
34
|
-
end
|
|
35
|
-
return newSet
|
|
36
|
-
end
|
|
37
|
-
function ____exports.combineSets(self, ...)
|
|
38
|
-
local sets = {...}
|
|
39
|
-
local newSet = __TS__New(Set)
|
|
40
|
-
for ____, set in ipairs(sets) do
|
|
41
|
-
for ____, value in __TS__Iterator(set:values()) do
|
|
42
|
-
newSet:add(value)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
return newSet
|
|
46
|
-
end
|
|
47
23
|
____exports.ensureAllCases = function(____, obj) return obj end
|
|
48
24
|
function ____exports.getEnumValues(self, transpiledEnum)
|
|
49
25
|
local enumValues = {}
|
|
@@ -96,4 +72,10 @@ function ____exports.tableClear(self, ____table)
|
|
|
96
72
|
____table[key] = nil
|
|
97
73
|
end
|
|
98
74
|
end
|
|
75
|
+
function ____exports.trimPrefix(self, ____string, prefix)
|
|
76
|
+
if not __TS__StringStartsWith(____string, prefix) then
|
|
77
|
+
return ____string
|
|
78
|
+
end
|
|
79
|
+
return __TS__StringSlice(____string, #prefix)
|
|
80
|
+
end
|
|
99
81
|
return ____exports
|
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export * from "./functions/random";
|
|
|
42
42
|
export * from "./functions/revive";
|
|
43
43
|
export * from "./functions/rooms";
|
|
44
44
|
export * from "./functions/seeds";
|
|
45
|
+
export * from "./functions/set";
|
|
45
46
|
export * from "./functions/spawnCollectible";
|
|
46
47
|
export * from "./functions/sprite";
|
|
47
48
|
export * from "./functions/stage";
|
package/dist/index.lua
CHANGED
|
@@ -342,6 +342,14 @@ do
|
|
|
342
342
|
end
|
|
343
343
|
end
|
|
344
344
|
end
|
|
345
|
+
do
|
|
346
|
+
local ____export = require("functions.set")
|
|
347
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
348
|
+
if ____exportKey ~= "default" then
|
|
349
|
+
____exports[____exportKey] = ____exportValue
|
|
350
|
+
end
|
|
351
|
+
end
|
|
352
|
+
end
|
|
345
353
|
do
|
|
346
354
|
local ____export = require("functions.spawnCollectible")
|
|
347
355
|
for ____exportKey, ____exportValue in pairs(____export) do
|