isaacscript-common 1.2.7 → 1.2.11
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/features/saveDataManager/exports.d.ts +17 -4
- package/dist/features/saveDataManager/exports.lua +8 -0
- package/dist/features/saveDataManager/main.lua +6 -0
- package/dist/functions/collectibleSet.lua +2 -2
- package/dist/functions/globals.lua +3 -2
- package/dist/functions/player.d.ts +8 -0
- package/dist/functions/player.lua +50 -14
- package/dist/functions/set.d.ts +15 -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 +2 -2
|
@@ -50,12 +50,17 @@ import { SaveData } from "../../types/SaveData";
|
|
|
50
50
|
* }
|
|
51
51
|
* ```
|
|
52
52
|
*
|
|
53
|
-
* - Save data is loaded from disk in the MC_POST_PLAYER_INIT callback
|
|
54
|
-
*
|
|
53
|
+
* - Save data is loaded from disk in the MC_POST_PLAYER_INIT callback (i.e. the first callback that
|
|
54
|
+
* can possibly run).
|
|
55
55
|
* - Save data is recorded to disk in the MC_PRE_GAME_EXIT callback.
|
|
56
56
|
*
|
|
57
57
|
* Note that before using the save data manager, you must call the [[`upgradeMod`]] function.
|
|
58
58
|
*
|
|
59
|
+
* If you want the save data manager to load data before the MC_POST_PLAYER_INIT callback (i.e. in
|
|
60
|
+
* the main menu), then you should explicitly call the [[`saveDataManagerLoad`]] function. (The save
|
|
61
|
+
* data manager cannot do this on its own because it cannot know when your mod features are finished
|
|
62
|
+
* initializing.)
|
|
63
|
+
*
|
|
59
64
|
* Finally, some features may have variables that need to be automatically reset per run/level, but
|
|
60
65
|
* not saved to disk on game exit. (For example, if they contain functions or other non-serializable
|
|
61
66
|
* data.) For these cases, set a special key of "dontSave" alongside "run", "level", and so forth.
|
|
@@ -65,8 +70,8 @@ import { SaveData } from "../../types/SaveData";
|
|
|
65
70
|
* @param saveData An object that corresponds to the `SaveData` interface. The object is
|
|
66
71
|
* conventionally called "v" for brevity (which is short for "local variables").
|
|
67
72
|
* @param conditionalFunc An optional function to run upon saving this key to disk. If the function
|
|
68
|
-
*
|
|
69
|
-
* "save#.dat" file with unnecessary keys.
|
|
73
|
+
* returns false, the key will not be written to disk. This allows mod features to avoid cluttering
|
|
74
|
+
* the "save#.dat" file with unnecessary keys.
|
|
70
75
|
*/
|
|
71
76
|
export declare function saveDataManager(key: string, saveData: SaveData, conditionalFunc?: () => boolean): void;
|
|
72
77
|
/**
|
|
@@ -75,6 +80,14 @@ export declare function saveDataManager(key: string, saveData: SaveData, conditi
|
|
|
75
80
|
* of its variables to disk immediately.
|
|
76
81
|
*/
|
|
77
82
|
export declare function saveDataManagerSave(): void;
|
|
83
|
+
/**
|
|
84
|
+
* The save data manager will automatically load variables from disk at the appropriate times (i.e.
|
|
85
|
+
* when a new run is started). Use this function to explicitly force the save data manager to load
|
|
86
|
+
* all of its variables from disk immediately.
|
|
87
|
+
*
|
|
88
|
+
* Note that doing this will overwrite current data, which can potentially result in lost state.
|
|
89
|
+
*/
|
|
90
|
+
export declare function saveDataManagerLoad(): void;
|
|
78
91
|
/**
|
|
79
92
|
* Sets the global variable of "g" equal to all of the save data variables for this mod.
|
|
80
93
|
* Sets the global variable of "gd" equal to all of the save data default variables for this mod.
|
|
@@ -10,6 +10,7 @@ local deepCopy = ____deepCopy.deepCopy
|
|
|
10
10
|
local SerializationType = ____deepCopy.SerializationType
|
|
11
11
|
local ____main = require("features.saveDataManager.main")
|
|
12
12
|
local FEATURE_NAME = ____main.FEATURE_NAME
|
|
13
|
+
local forceSaveDataManagerLoad = ____main.forceSaveDataManagerLoad
|
|
13
14
|
local forceSaveDataManagerSave = ____main.forceSaveDataManagerSave
|
|
14
15
|
local isSaveDataManagerInitialized = ____main.isSaveDataManagerInitialized
|
|
15
16
|
local ____maps = require("features.saveDataManager.maps")
|
|
@@ -48,6 +49,13 @@ function ____exports.saveDataManagerSave(self)
|
|
|
48
49
|
end
|
|
49
50
|
forceSaveDataManagerSave(nil)
|
|
50
51
|
end
|
|
52
|
+
function ____exports.saveDataManagerLoad(self)
|
|
53
|
+
if not isSaveDataManagerInitialized(nil) then
|
|
54
|
+
local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
|
|
55
|
+
error(msg)
|
|
56
|
+
end
|
|
57
|
+
forceSaveDataManagerLoad(nil)
|
|
58
|
+
end
|
|
51
59
|
function ____exports.saveDataManagerSetGlobal(self)
|
|
52
60
|
g = saveDataMap
|
|
53
61
|
gd = saveDataDefaultsMap
|
|
@@ -109,4 +109,10 @@ function ____exports.forceSaveDataManagerSave(self)
|
|
|
109
109
|
end
|
|
110
110
|
saveToDisk(nil, mod, saveDataMap, saveDataConditionalFuncMap)
|
|
111
111
|
end
|
|
112
|
+
function ____exports.forceSaveDataManagerLoad(self)
|
|
113
|
+
if mod == nil then
|
|
114
|
+
return
|
|
115
|
+
end
|
|
116
|
+
loadFromDisk(nil, mod, saveDataMap)
|
|
117
|
+
end
|
|
112
118
|
return ____exports
|
|
@@ -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,12 @@ 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 proper name of the player. Use this instead of the
|
|
136
|
+
* `EntityPlayer.GetName` method because it accounts for Blue Baby, Lazarus II, and Tainted
|
|
137
|
+
* characters.
|
|
138
|
+
*/
|
|
139
|
+
export declare function getPlayerName(player: EntityPlayer): string;
|
|
134
140
|
/**
|
|
135
141
|
* Returns the combined value of all of the player's red hearts, soul/black hearts, and bone hearts,
|
|
136
142
|
* minus the value of the player's rotten hearts.
|
|
@@ -207,6 +213,8 @@ export declare function isLost(player: EntityPlayer): boolean;
|
|
|
207
213
|
* Deals. (e.g. The Lost, Tainted Lost, etc.)
|
|
208
214
|
*/
|
|
209
215
|
export declare function canTakeFreeDevilDeals(player: EntityPlayer): boolean;
|
|
216
|
+
/** Helper function for detecting if a player is one of the Tainted characters. */
|
|
217
|
+
export declare function isTainted(player: EntityPlayer): boolean;
|
|
210
218
|
/** Helper function for detecting when a player is Tainted Lazarus or Dead Tainted Lazarus. */
|
|
211
219
|
export declare function isTaintedLazarus(player: EntityPlayer): boolean;
|
|
212
220
|
export declare function removeCollectibleCostume(player: EntityPlayer, collectibleType: CollectibleType | int): void;
|
|
@@ -9,7 +9,7 @@ local __TS__Iterator = ____lualib.__TS__Iterator
|
|
|
9
9
|
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
10
10
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
11
11
|
local ____exports = {}
|
|
12
|
-
local EXCLUDED_CHARACTERS
|
|
12
|
+
local getAdjustedPlayerName, EXCLUDED_CHARACTERS
|
|
13
13
|
local ____constants = require("constants")
|
|
14
14
|
local CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART = ____constants.CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART
|
|
15
15
|
local CHARACTERS_WITH_FREE_DEVIL_DEALS = ____constants.CHARACTERS_WITH_FREE_DEVIL_DEALS
|
|
@@ -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
|
|
@@ -66,6 +67,29 @@ function ____exports.getPlayerMaxHeartContainers(self, player)
|
|
|
66
67
|
end
|
|
67
68
|
return maxHeartContainers
|
|
68
69
|
end
|
|
70
|
+
function getAdjustedPlayerName(self, player)
|
|
71
|
+
local character = player:GetPlayerType()
|
|
72
|
+
repeat
|
|
73
|
+
local ____switch71 = character
|
|
74
|
+
local ____cond71 = ____switch71 == PlayerType.PLAYER_BLUEBABY or ____switch71 == PlayerType.PLAYER_BLUEBABY_B
|
|
75
|
+
if ____cond71 then
|
|
76
|
+
do
|
|
77
|
+
return "Blue Baby"
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_LAZARUS2
|
|
81
|
+
if ____cond71 then
|
|
82
|
+
do
|
|
83
|
+
return "Lazarus II"
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
do
|
|
87
|
+
do
|
|
88
|
+
return player:GetName()
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
until true
|
|
92
|
+
end
|
|
69
93
|
function ____exports.getPlayers(self, performExclusions)
|
|
70
94
|
if performExclusions == nil then
|
|
71
95
|
performExclusions = false
|
|
@@ -78,18 +102,18 @@ function ____exports.getPlayers(self, performExclusions)
|
|
|
78
102
|
do
|
|
79
103
|
local player = Isaac.GetPlayer(i)
|
|
80
104
|
if player == nil then
|
|
81
|
-
goto
|
|
105
|
+
goto __continue77
|
|
82
106
|
end
|
|
83
107
|
if ____exports.isChildPlayer(nil, player) then
|
|
84
|
-
goto
|
|
108
|
+
goto __continue77
|
|
85
109
|
end
|
|
86
110
|
local character = player:GetPlayerType()
|
|
87
111
|
if performExclusions and EXCLUDED_CHARACTERS:has(character) then
|
|
88
|
-
goto
|
|
112
|
+
goto __continue77
|
|
89
113
|
end
|
|
90
114
|
__TS__ArrayPush(players, player)
|
|
91
115
|
end
|
|
92
|
-
::
|
|
116
|
+
::__continue77::
|
|
93
117
|
i = i + 1
|
|
94
118
|
end
|
|
95
119
|
end
|
|
@@ -98,6 +122,10 @@ end
|
|
|
98
122
|
function ____exports.isChildPlayer(self, player)
|
|
99
123
|
return player.Parent ~= nil
|
|
100
124
|
end
|
|
125
|
+
function ____exports.isTainted(self, player)
|
|
126
|
+
local character = player:GetPlayerType()
|
|
127
|
+
return character >= PlayerType.PLAYER_ISAAC_B
|
|
128
|
+
end
|
|
101
129
|
EXCLUDED_CHARACTERS = __TS__New(Set, {PlayerType.PLAYER_ESAU, PlayerType.PLAYER_THESOUL_B})
|
|
102
130
|
function ____exports.addCollectibleCostume(self, player, collectibleType)
|
|
103
131
|
local itemConfig = Isaac.GetItemConfig()
|
|
@@ -307,6 +335,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
|
|
|
307
335
|
end
|
|
308
336
|
return nil
|
|
309
337
|
end
|
|
338
|
+
function ____exports.getPlayerName(self, player)
|
|
339
|
+
local adjustedName = getAdjustedPlayerName(nil, player)
|
|
340
|
+
if not ____exports.isTainted(nil, player) then
|
|
341
|
+
return adjustedName
|
|
342
|
+
end
|
|
343
|
+
local baseName = trimPrefix(nil, adjustedName, "The ")
|
|
344
|
+
return "Tainted " .. baseName
|
|
345
|
+
end
|
|
310
346
|
function ____exports.getPlayerNumHitsRemaining(self, player)
|
|
311
347
|
local hearts = player:GetHearts()
|
|
312
348
|
local soulHearts = player:GetSoulHearts()
|
|
@@ -463,9 +499,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
463
499
|
itemPool:RemoveCollectible(collectibleType)
|
|
464
500
|
end
|
|
465
501
|
repeat
|
|
466
|
-
local
|
|
467
|
-
local
|
|
468
|
-
if
|
|
502
|
+
local ____switch117 = activeSlot
|
|
503
|
+
local ____cond117 = ____switch117 == ActiveSlot.SLOT_PRIMARY
|
|
504
|
+
if ____cond117 then
|
|
469
505
|
do
|
|
470
506
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
471
507
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -474,8 +510,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
474
510
|
break
|
|
475
511
|
end
|
|
476
512
|
end
|
|
477
|
-
|
|
478
|
-
if
|
|
513
|
+
____cond117 = ____cond117 or ____switch117 == ActiveSlot.SLOT_SECONDARY
|
|
514
|
+
if ____cond117 then
|
|
479
515
|
do
|
|
480
516
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
481
517
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -490,16 +526,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
490
526
|
break
|
|
491
527
|
end
|
|
492
528
|
end
|
|
493
|
-
|
|
494
|
-
if
|
|
529
|
+
____cond117 = ____cond117 or ____switch117 == ActiveSlot.SLOT_POCKET
|
|
530
|
+
if ____cond117 then
|
|
495
531
|
do
|
|
496
532
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
497
533
|
player:SetActiveCharge(charge, activeSlot)
|
|
498
534
|
break
|
|
499
535
|
end
|
|
500
536
|
end
|
|
501
|
-
|
|
502
|
-
if
|
|
537
|
+
____cond117 = ____cond117 or ____switch117 == ActiveSlot.SLOT_POCKET2
|
|
538
|
+
if ____cond117 then
|
|
503
539
|
do
|
|
504
540
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
505
541
|
break
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
/** Helper function to copy a set. (You can also use a Set constructor to accomplish this task.) */
|
|
9
|
+
export declare function copySet<T>(oldSet: Set<T>): Set<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Helper function to create a new set that is the composition of two or more sets.
|
|
12
|
+
*
|
|
13
|
+
* This function is variadic, meaning that you can specify N sets.
|
|
14
|
+
*/
|
|
15
|
+
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
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.336",
|
|
30
30
|
"isaacscript-lint": "^1.0.79",
|
|
31
31
|
"isaacscript-tsconfig": "^1.1.8",
|
|
32
32
|
"typedoc": "^0.22.11",
|