isaacscript-common 1.2.6 → 1.2.10
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/constants.d.ts +4 -2
- package/dist/constants.lua +4 -2
- package/dist/features/disableInputs.lua +4 -4
- 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/input.lua +29 -46
- package/dist/functions/math.d.ts +2 -0
- package/dist/functions/math.lua +11 -0
- package/dist/functions/player.d.ts +7 -0
- package/dist/functions/player.lua +27 -13
- 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
package/dist/constants.d.ts
CHANGED
|
@@ -104,10 +104,12 @@ export declare const MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B;
|
|
|
104
104
|
export declare const MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING;
|
|
105
105
|
export declare const SECOND_IN_MILLISECONDS = 1000;
|
|
106
106
|
export declare const MINUTE_IN_MILLISECONDS: number;
|
|
107
|
-
export declare const MOVEMENT_ACTIONS:
|
|
107
|
+
export declare const MOVEMENT_ACTIONS: ButtonAction[];
|
|
108
|
+
export declare const MOVEMENT_ACTIONS_SET: Set<ButtonAction>;
|
|
108
109
|
export declare const ONE_BY_ONE_ROOM_GRID_SIZE = 135;
|
|
109
110
|
export declare const SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES: Set<CollectibleType>;
|
|
110
|
-
export declare const SHOOTING_ACTIONS:
|
|
111
|
+
export declare const SHOOTING_ACTIONS: ButtonAction[];
|
|
112
|
+
export declare const SHOOTING_ACTIONS_SET: Set<ButtonAction>;
|
|
111
113
|
export declare const STORY_BOSSES: Set<EntityType>;
|
|
112
114
|
/**
|
|
113
115
|
* This is the number of draw coordinates that each heart spans on the UI in the upper left hand
|
package/dist/constants.lua
CHANGED
|
@@ -90,7 +90,8 @@ ____exports.MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B
|
|
|
90
90
|
____exports.MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING
|
|
91
91
|
____exports.SECOND_IN_MILLISECONDS = 1000
|
|
92
92
|
____exports.MINUTE_IN_MILLISECONDS = 60 * ____exports.SECOND_IN_MILLISECONDS
|
|
93
|
-
____exports.MOVEMENT_ACTIONS =
|
|
93
|
+
____exports.MOVEMENT_ACTIONS = {ButtonAction.ACTION_LEFT, ButtonAction.ACTION_RIGHT, ButtonAction.ACTION_UP, ButtonAction.ACTION_DOWN}
|
|
94
|
+
____exports.MOVEMENT_ACTIONS_SET = __TS__New(Set, ____exports.MOVEMENT_ACTIONS)
|
|
94
95
|
____exports.ONE_BY_ONE_ROOM_GRID_SIZE = 135
|
|
95
96
|
____exports.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = __TS__New(Set, {
|
|
96
97
|
CollectibleType.COLLECTIBLE_FORGET_ME_NOW,
|
|
@@ -102,7 +103,8 @@ ____exports.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = __TS__New(Set, {
|
|
|
102
103
|
CollectibleType.COLLECTIBLE_DEATH_CERTIFICATE,
|
|
103
104
|
CollectibleType.COLLECTIBLE_R_KEY
|
|
104
105
|
})
|
|
105
|
-
____exports.SHOOTING_ACTIONS =
|
|
106
|
+
____exports.SHOOTING_ACTIONS = {ButtonAction.ACTION_SHOOTLEFT, ButtonAction.ACTION_SHOOTRIGHT, ButtonAction.ACTION_SHOOTUP, ButtonAction.ACTION_SHOOTDOWN}
|
|
107
|
+
____exports.SHOOTING_ACTIONS_SET = __TS__New(Set, ____exports.SHOOTING_ACTIONS)
|
|
106
108
|
____exports.STORY_BOSSES = __TS__New(Set, {
|
|
107
109
|
EntityType.ENTITY_MOM,
|
|
108
110
|
EntityType.ENTITY_MOMS_HEART,
|
|
@@ -4,8 +4,8 @@ local Set = ____lualib.Set
|
|
|
4
4
|
local ____exports = {}
|
|
5
5
|
local isActionPressed, isActionTriggered, getActionValue, getReturnValue, v
|
|
6
6
|
local ____constants = require("constants")
|
|
7
|
-
local
|
|
8
|
-
local
|
|
7
|
+
local MOVEMENT_ACTIONS_SET = ____constants.MOVEMENT_ACTIONS_SET
|
|
8
|
+
local SHOOTING_ACTIONS_SET = ____constants.SHOOTING_ACTIONS_SET
|
|
9
9
|
local ____errors = require("errors")
|
|
10
10
|
local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
|
|
11
11
|
local ____exports = require("features.saveDataManager.exports")
|
|
@@ -85,9 +85,9 @@ function ____exports.disableAllInputsExceptFor(self, whitelist)
|
|
|
85
85
|
v.run.blacklist = nil
|
|
86
86
|
end
|
|
87
87
|
function ____exports.disableMovementInputs(self)
|
|
88
|
-
____exports.enableAllInputsExceptFor(nil,
|
|
88
|
+
____exports.enableAllInputsExceptFor(nil, MOVEMENT_ACTIONS_SET)
|
|
89
89
|
end
|
|
90
90
|
function ____exports.disableShootingInputs(self)
|
|
91
|
-
____exports.enableAllInputsExceptFor(nil,
|
|
91
|
+
____exports.enableAllInputsExceptFor(nil, SHOOTING_ACTIONS_SET)
|
|
92
92
|
end
|
|
93
93
|
return ____exports
|
|
@@ -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
|
package/dist/functions/input.lua
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
|
-
local Set = ____lualib.Set
|
|
4
3
|
local __TS__StringReplace = ____lualib.__TS__StringReplace
|
|
5
4
|
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
|
|
6
|
-
local
|
|
5
|
+
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
7
6
|
local __TS__StringSlice = ____lualib.__TS__StringSlice
|
|
8
7
|
local ____exports = {}
|
|
9
8
|
local ____constants = require("constants")
|
|
10
9
|
local MAX_NUM_INPUTS = ____constants.MAX_NUM_INPUTS
|
|
11
10
|
local MOVEMENT_ACTIONS = ____constants.MOVEMENT_ACTIONS
|
|
12
11
|
local SHOOTING_ACTIONS = ____constants.SHOOTING_ACTIONS
|
|
12
|
+
local ____math = require("functions.math")
|
|
13
|
+
local range = ____math.range
|
|
13
14
|
local ControllerLiteral = ControllerLiteral or ({})
|
|
14
15
|
ControllerLiteral.DPAD_LEFT = 0
|
|
15
16
|
ControllerLiteral[ControllerLiteral.DPAD_LEFT] = "DPAD_LEFT"
|
|
@@ -72,63 +73,45 @@ function ____exports.controllerToString(self, controller)
|
|
|
72
73
|
return "unknown"
|
|
73
74
|
end
|
|
74
75
|
function ____exports.isActionPressedOnAnyInput(self, buttonAction)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
end
|
|
81
|
-
i = i + 1
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
return false
|
|
76
|
+
local validInputs = range(nil, 0, MAX_NUM_INPUTS - 1)
|
|
77
|
+
return __TS__ArraySome(
|
|
78
|
+
validInputs,
|
|
79
|
+
function(____, input) return Input.IsActionPressed(buttonAction, input) end
|
|
80
|
+
)
|
|
85
81
|
end
|
|
86
82
|
function ____exports.isActionTriggeredOnAnyInput(self, buttonAction)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
end
|
|
93
|
-
i = i + 1
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
return false
|
|
83
|
+
local validInputs = range(nil, 0, MAX_NUM_INPUTS - 1)
|
|
84
|
+
return __TS__ArraySome(
|
|
85
|
+
validInputs,
|
|
86
|
+
function(____, input) return Input.IsActionTriggered(buttonAction, input) end
|
|
87
|
+
)
|
|
97
88
|
end
|
|
98
89
|
function ____exports.isKeyboardPressed(self, key)
|
|
99
90
|
return Input.IsButtonPressed(key, 0)
|
|
100
91
|
end
|
|
101
92
|
function ____exports.isMoveActionPressedOnAnyInput(self)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
end
|
|
107
|
-
return false
|
|
93
|
+
return __TS__ArraySome(
|
|
94
|
+
MOVEMENT_ACTIONS,
|
|
95
|
+
function(____, moveAction) return ____exports.isActionPressedOnAnyInput(nil, moveAction) end
|
|
96
|
+
)
|
|
108
97
|
end
|
|
109
98
|
function ____exports.isMoveActionTriggeredOnAnyInput(self)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
end
|
|
115
|
-
return false
|
|
99
|
+
return __TS__ArraySome(
|
|
100
|
+
MOVEMENT_ACTIONS,
|
|
101
|
+
function(____, moveAction) return ____exports.isActionTriggeredOnAnyInput(nil, moveAction) end
|
|
102
|
+
)
|
|
116
103
|
end
|
|
117
104
|
function ____exports.isShootActionPressedOnAnyInput(self)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
end
|
|
123
|
-
return false
|
|
105
|
+
return __TS__ArraySome(
|
|
106
|
+
SHOOTING_ACTIONS,
|
|
107
|
+
function(____, shootAction) return ____exports.isActionPressedOnAnyInput(nil, shootAction) end
|
|
108
|
+
)
|
|
124
109
|
end
|
|
125
110
|
function ____exports.isShootActionTriggeredOnAnyInput(self)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
end
|
|
131
|
-
return false
|
|
111
|
+
return __TS__ArraySome(
|
|
112
|
+
SHOOTING_ACTIONS,
|
|
113
|
+
function(____, shootAction) return ____exports.isActionTriggeredOnAnyInput(nil, shootAction) end
|
|
114
|
+
)
|
|
132
115
|
end
|
|
133
116
|
function ____exports.keyboardToString(self, keyboard)
|
|
134
117
|
for ____, ____value in ipairs(__TS__ObjectEntries(Keyboard)) do
|
package/dist/functions/math.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export declare function isEven(num: int): boolean;
|
|
|
17
17
|
export declare function isOdd(num: int): boolean;
|
|
18
18
|
export declare function lerp(a: number, b: number, pos: float): number;
|
|
19
19
|
export declare function lerpAngleDegrees(aStart: number, aEnd: number, percent: float): number;
|
|
20
|
+
/** Helper function to return an array with the elements from start to end, inclusive. */
|
|
21
|
+
export declare function range(start: int, end: int): int[];
|
|
20
22
|
/**
|
|
21
23
|
* If rounding fails, this function returns 0.
|
|
22
24
|
* From: http://lua-users.org/wiki/SimpleRound
|
package/dist/functions/math.lua
CHANGED
|
@@ -87,6 +87,17 @@ end
|
|
|
87
87
|
function ____exports.lerpAngleDegrees(self, aStart, aEnd, percent)
|
|
88
88
|
return aStart + ____exports.getAngleDifference(nil, aStart, aEnd) * percent
|
|
89
89
|
end
|
|
90
|
+
function ____exports.range(self, start, ____end)
|
|
91
|
+
local array = {}
|
|
92
|
+
do
|
|
93
|
+
local i = start
|
|
94
|
+
while i <= ____end do
|
|
95
|
+
__TS__ArrayPush(array, i)
|
|
96
|
+
i = i + 1
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
return array
|
|
100
|
+
end
|
|
90
101
|
function ____exports.round(self, num, numDecimalPlaces)
|
|
91
102
|
if numDecimalPlaces == nil then
|
|
92
103
|
numDecimalPlaces = 0
|
|
@@ -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 fill in "???" and 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,15 @@ 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
|
+
local filledInName = name == "???" and "Blue Baby" or name
|
|
318
|
+
if not ____exports.isTainted(nil, player) then
|
|
319
|
+
return filledInName
|
|
320
|
+
end
|
|
321
|
+
local baseName = trimPrefix(nil, filledInName, "The ")
|
|
322
|
+
return "Tainted " .. baseName
|
|
323
|
+
end
|
|
310
324
|
function ____exports.getPlayerNumHitsRemaining(self, player)
|
|
311
325
|
local hearts = player:GetHearts()
|
|
312
326
|
local soulHearts = player:GetSoulHearts()
|
|
@@ -463,9 +477,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
463
477
|
itemPool:RemoveCollectible(collectibleType)
|
|
464
478
|
end
|
|
465
479
|
repeat
|
|
466
|
-
local
|
|
467
|
-
local
|
|
468
|
-
if
|
|
480
|
+
local ____switch112 = activeSlot
|
|
481
|
+
local ____cond112 = ____switch112 == ActiveSlot.SLOT_PRIMARY
|
|
482
|
+
if ____cond112 then
|
|
469
483
|
do
|
|
470
484
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
471
485
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -474,8 +488,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
474
488
|
break
|
|
475
489
|
end
|
|
476
490
|
end
|
|
477
|
-
|
|
478
|
-
if
|
|
491
|
+
____cond112 = ____cond112 or ____switch112 == ActiveSlot.SLOT_SECONDARY
|
|
492
|
+
if ____cond112 then
|
|
479
493
|
do
|
|
480
494
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
481
495
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -490,16 +504,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
490
504
|
break
|
|
491
505
|
end
|
|
492
506
|
end
|
|
493
|
-
|
|
494
|
-
if
|
|
507
|
+
____cond112 = ____cond112 or ____switch112 == ActiveSlot.SLOT_POCKET
|
|
508
|
+
if ____cond112 then
|
|
495
509
|
do
|
|
496
510
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
497
511
|
player:SetActiveCharge(charge, activeSlot)
|
|
498
512
|
break
|
|
499
513
|
end
|
|
500
514
|
end
|
|
501
|
-
|
|
502
|
-
if
|
|
515
|
+
____cond112 = ____cond112 or ____switch112 == ActiveSlot.SLOT_POCKET2
|
|
516
|
+
if ____cond112 then
|
|
503
517
|
do
|
|
504
518
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
505
519
|
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.10",
|
|
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",
|