isaacscript-common 1.0.601 → 1.0.605
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/globals.d.ts +14 -0
- package/dist/functions/globals.lua +220 -0
- package/dist/functions/jsonRoom.lua +36 -26
- package/dist/functions/npc.lua +17 -23
- package/dist/functions/player.d.ts +3 -1
- package/dist/functions/player.lua +59 -54
- package/dist/functions/util.d.ts +13 -0
- package/dist/functions/util.lua +18 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.lua +8 -0
- package/package.json +2 -2
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to get a set containing all of the global variable names that are contained
|
|
4
|
+
* within the Isaac environment by default.
|
|
5
|
+
*
|
|
6
|
+
* Returns a slightly different set depending on whether the "--luadebug" flag is enabled or not.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDefaultGlobals(): Set<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Helper function to get an array of any added global variables in the Isaac Lua environment.
|
|
11
|
+
* Returns an array of key/value tuples.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getNewGlobals(): [AnyNotNil, unknown][];
|
|
14
|
+
export declare function logNewGlobals(): void;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
require("lualib_bundle");
|
|
3
|
+
local ____exports = {}
|
|
4
|
+
local twoDimensionalSort
|
|
5
|
+
local ____log = require("functions.log")
|
|
6
|
+
local log = ____log.log
|
|
7
|
+
local ____util = require("functions.util")
|
|
8
|
+
local addSetsToSet = ____util.addSetsToSet
|
|
9
|
+
local copySet = ____util.copySet
|
|
10
|
+
local isLuaDebugEnabled = ____util.isLuaDebugEnabled
|
|
11
|
+
function twoDimensionalSort(self, a, b)
|
|
12
|
+
if a[1] == b[1] then
|
|
13
|
+
return 0
|
|
14
|
+
end
|
|
15
|
+
return a[1] < b[1] and -1 or 1
|
|
16
|
+
end
|
|
17
|
+
local DEFAULT_GLOBALS = __TS__New(Set, {
|
|
18
|
+
"ActionTriggers",
|
|
19
|
+
"ActiveSlot",
|
|
20
|
+
"BabySubType",
|
|
21
|
+
"BackdropType",
|
|
22
|
+
"BatterySubType",
|
|
23
|
+
"BedSubType",
|
|
24
|
+
"BitSet128",
|
|
25
|
+
"BombSubType",
|
|
26
|
+
"BombVariant",
|
|
27
|
+
"ButtonAction",
|
|
28
|
+
"CacheFlag",
|
|
29
|
+
"Card",
|
|
30
|
+
"Challenge",
|
|
31
|
+
"ChampionColor",
|
|
32
|
+
"ChestSubType",
|
|
33
|
+
"CoinSubType",
|
|
34
|
+
"CollectibleType",
|
|
35
|
+
"Color",
|
|
36
|
+
"CppContainer",
|
|
37
|
+
"DamageFlag",
|
|
38
|
+
"Difficulty",
|
|
39
|
+
"Direction",
|
|
40
|
+
"DoorSlot",
|
|
41
|
+
"DoorState",
|
|
42
|
+
"DoorVariant",
|
|
43
|
+
"EffectVariant",
|
|
44
|
+
"Entity",
|
|
45
|
+
"EntityBomb",
|
|
46
|
+
"EntityCollisionClass",
|
|
47
|
+
"EntityEffect",
|
|
48
|
+
"EntityFamiliar",
|
|
49
|
+
"EntityFlag",
|
|
50
|
+
"EntityGridCollisionClass",
|
|
51
|
+
"EntityKnife",
|
|
52
|
+
"EntityLaser",
|
|
53
|
+
"EntityNPC",
|
|
54
|
+
"EntityPartition",
|
|
55
|
+
"EntityPickup",
|
|
56
|
+
"EntityPlayer",
|
|
57
|
+
"EntityProjectile",
|
|
58
|
+
"EntityPtr",
|
|
59
|
+
"EntityRef",
|
|
60
|
+
"EntityTear",
|
|
61
|
+
"EntityType",
|
|
62
|
+
"FamiliarVariant",
|
|
63
|
+
"Font",
|
|
64
|
+
"Game",
|
|
65
|
+
"GameStateFlag",
|
|
66
|
+
"GetPtrHash",
|
|
67
|
+
"GridCollisionClass",
|
|
68
|
+
"GridEntity",
|
|
69
|
+
"GridEntityDesc",
|
|
70
|
+
"GridEntityDoor",
|
|
71
|
+
"GridEntityPit",
|
|
72
|
+
"GridEntityPoop",
|
|
73
|
+
"GridEntityPressurePlate",
|
|
74
|
+
"GridEntityRock",
|
|
75
|
+
"GridEntitySpikes",
|
|
76
|
+
"GridEntityTNT",
|
|
77
|
+
"GridEntityType",
|
|
78
|
+
"GridRooms",
|
|
79
|
+
"HUD",
|
|
80
|
+
"HeartSubType",
|
|
81
|
+
"Input",
|
|
82
|
+
"InputHook",
|
|
83
|
+
"Isaac",
|
|
84
|
+
"ItemConfig",
|
|
85
|
+
"ItemPool",
|
|
86
|
+
"ItemPoolType",
|
|
87
|
+
"ItemType",
|
|
88
|
+
"KColor",
|
|
89
|
+
"KeySubType",
|
|
90
|
+
"Keyboard",
|
|
91
|
+
"LaserOffset",
|
|
92
|
+
"LaserSubType",
|
|
93
|
+
"Level",
|
|
94
|
+
"LevelCurse",
|
|
95
|
+
"LevelStage",
|
|
96
|
+
"LevelStateFlag",
|
|
97
|
+
"LocustSubtypes",
|
|
98
|
+
"ModCallbacks",
|
|
99
|
+
"Mouse",
|
|
100
|
+
"Music",
|
|
101
|
+
"MusicManager",
|
|
102
|
+
"NpcState",
|
|
103
|
+
"NullItemID",
|
|
104
|
+
"Options",
|
|
105
|
+
"PathFinder",
|
|
106
|
+
"PickupPrice",
|
|
107
|
+
"PickupVariant",
|
|
108
|
+
"PillColor",
|
|
109
|
+
"PillEffect",
|
|
110
|
+
"PlayerForm",
|
|
111
|
+
"PlayerSpriteLayer",
|
|
112
|
+
"PlayerType",
|
|
113
|
+
"PlayerTypes",
|
|
114
|
+
"PoopPickupSubType",
|
|
115
|
+
"PoopSpellType",
|
|
116
|
+
"ProjectileFlags",
|
|
117
|
+
"ProjectileParams",
|
|
118
|
+
"ProjectileVariant",
|
|
119
|
+
"QueueItemData",
|
|
120
|
+
"REPENTANCE",
|
|
121
|
+
"RNG",
|
|
122
|
+
"Random",
|
|
123
|
+
"RandomVector",
|
|
124
|
+
"RegisterMod",
|
|
125
|
+
"RenderMode",
|
|
126
|
+
"Room",
|
|
127
|
+
"RoomConfig",
|
|
128
|
+
"RoomDescriptor",
|
|
129
|
+
"RoomShape",
|
|
130
|
+
"RoomTransitionAnim",
|
|
131
|
+
"RoomType",
|
|
132
|
+
"SFXManager",
|
|
133
|
+
"SackSubType",
|
|
134
|
+
"SeedEffect",
|
|
135
|
+
"Seeds",
|
|
136
|
+
"ShockwaveParams",
|
|
137
|
+
"SortingLayer",
|
|
138
|
+
"SoundEffect",
|
|
139
|
+
"Sprite",
|
|
140
|
+
"StageType",
|
|
141
|
+
"StartDebug",
|
|
142
|
+
"TearFlags",
|
|
143
|
+
"TearParams",
|
|
144
|
+
"TearVariant",
|
|
145
|
+
"TemporaryEffect",
|
|
146
|
+
"TemporaryEffects",
|
|
147
|
+
"TrinketType",
|
|
148
|
+
"UseFlag",
|
|
149
|
+
"Vector",
|
|
150
|
+
"WeaponType",
|
|
151
|
+
"_G",
|
|
152
|
+
"_VERSION",
|
|
153
|
+
"assert",
|
|
154
|
+
"collectgarbage",
|
|
155
|
+
"coroutine",
|
|
156
|
+
"dofile",
|
|
157
|
+
"error",
|
|
158
|
+
"getmetatable",
|
|
159
|
+
"include",
|
|
160
|
+
"ipairs",
|
|
161
|
+
"load",
|
|
162
|
+
"loadfile",
|
|
163
|
+
"math",
|
|
164
|
+
"next",
|
|
165
|
+
"pairs",
|
|
166
|
+
"pcall",
|
|
167
|
+
"print",
|
|
168
|
+
"rawequal",
|
|
169
|
+
"rawget",
|
|
170
|
+
"rawlen",
|
|
171
|
+
"rawset",
|
|
172
|
+
"require",
|
|
173
|
+
"select",
|
|
174
|
+
"setmetatable",
|
|
175
|
+
"string",
|
|
176
|
+
"table",
|
|
177
|
+
"tonumber",
|
|
178
|
+
"tostring",
|
|
179
|
+
"type",
|
|
180
|
+
"utf8",
|
|
181
|
+
"xpcall"
|
|
182
|
+
})
|
|
183
|
+
local LUA_DEBUG_ADDED_GLOBALS = __TS__New(Set, {"debug", "io", "os", "package"})
|
|
184
|
+
local RACING_PLUS_SANDBOX_ADDED_GLOBALS = __TS__New(Set, {"sandboxTraceback", "sandboxGetTraceback", "getParentFunctionDescription"})
|
|
185
|
+
function ____exports.getDefaultGlobals(self)
|
|
186
|
+
local defaultGlobals = copySet(nil, DEFAULT_GLOBALS)
|
|
187
|
+
if isLuaDebugEnabled(nil) then
|
|
188
|
+
addSetsToSet(nil, defaultGlobals, LUA_DEBUG_ADDED_GLOBALS)
|
|
189
|
+
end
|
|
190
|
+
addSetsToSet(nil, defaultGlobals, RACING_PLUS_SANDBOX_ADDED_GLOBALS)
|
|
191
|
+
return defaultGlobals
|
|
192
|
+
end
|
|
193
|
+
function ____exports.getNewGlobals(self)
|
|
194
|
+
local defaultGlobals = ____exports.getDefaultGlobals(nil)
|
|
195
|
+
local newGlobals = {}
|
|
196
|
+
for key, value in pairs(_G) do
|
|
197
|
+
if not defaultGlobals:has(key) then
|
|
198
|
+
local keyValueTuple = {key, value}
|
|
199
|
+
__TS__ArrayPush(newGlobals, keyValueTuple)
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
__TS__ArraySort(newGlobals, twoDimensionalSort)
|
|
203
|
+
return newGlobals
|
|
204
|
+
end
|
|
205
|
+
function ____exports.logNewGlobals(self)
|
|
206
|
+
local newGlobals = ____exports.getNewGlobals(nil)
|
|
207
|
+
log("List of added global variables in the Isaac environment:")
|
|
208
|
+
if #newGlobals == 0 then
|
|
209
|
+
log("- n/a (no extra global variables found)")
|
|
210
|
+
end
|
|
211
|
+
do
|
|
212
|
+
local i = 0
|
|
213
|
+
while i < #newGlobals do
|
|
214
|
+
local key, value = table.unpack(newGlobals[i + 1])
|
|
215
|
+
log((((tostring(i + 1) .. ") ") .. tostring(key)) .. " - ") .. tostring(value))
|
|
216
|
+
i = i + 1
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
return ____exports
|
|
@@ -2,56 +2,66 @@
|
|
|
2
2
|
require("lualib_bundle");
|
|
3
3
|
local ____exports = {}
|
|
4
4
|
local getTotalWeightOfJSONRooms, getJSONRoomWithChosenWeight
|
|
5
|
+
local ____array = require("functions.array")
|
|
6
|
+
local arraySum = ____array.arraySum
|
|
5
7
|
local ____log = require("functions.log")
|
|
6
8
|
local log = ____log.log
|
|
7
9
|
local ____random = require("functions.random")
|
|
8
10
|
local getRandomFloat = ____random.getRandomFloat
|
|
9
11
|
function getTotalWeightOfJSONRooms(self, jsonRooms)
|
|
10
|
-
local
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
local weights = __TS__ArrayMap(
|
|
13
|
+
jsonRooms,
|
|
14
|
+
function(____, jsonRoom)
|
|
15
|
+
local roomWeightString = jsonRoom["$"].weight
|
|
16
|
+
local roomWeight = tonumber(roomWeightString)
|
|
17
|
+
if roomWeight == nil then
|
|
18
|
+
error(("Failed to parse the weight of a JSON room: " .. roomWeightString) .. ".")
|
|
19
|
+
end
|
|
20
|
+
return roomWeight
|
|
16
21
|
end
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return totalWeight
|
|
22
|
+
)
|
|
23
|
+
return arraySum(nil, weights)
|
|
20
24
|
end
|
|
21
25
|
function getJSONRoomWithChosenWeight(self, jsonRooms, chosenWeight)
|
|
22
26
|
for ____, jsonRoom in ipairs(jsonRooms) do
|
|
23
27
|
local roomWeightString = jsonRoom["$"].weight
|
|
24
28
|
local roomWeight = tonumber(roomWeightString)
|
|
25
29
|
if roomWeight == nil then
|
|
26
|
-
error("Failed to parse the weight of a room: " .. roomWeightString)
|
|
30
|
+
error("Failed to parse the weight of a JSON room: " .. roomWeightString)
|
|
27
31
|
end
|
|
28
32
|
if chosenWeight < roomWeight then
|
|
29
33
|
return jsonRoom
|
|
30
34
|
end
|
|
31
35
|
chosenWeight = chosenWeight - roomWeight
|
|
32
36
|
end
|
|
33
|
-
return error("Failed to get a room with chosen weight: " .. tostring(chosenWeight))
|
|
37
|
+
return error("Failed to get a JSON room with chosen weight: " .. tostring(chosenWeight))
|
|
34
38
|
end
|
|
35
39
|
function ____exports.getJSONRoomOfVariant(self, jsonRooms, variant)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
local jsonRoomsOfVariant = __TS__ArrayFilter(
|
|
41
|
+
jsonRooms,
|
|
42
|
+
function(____, jsonRoom)
|
|
43
|
+
local roomVariantString = jsonRoom["$"].variant
|
|
44
|
+
local roomVariant = tonumber(roomVariantString)
|
|
45
|
+
return roomVariant == variant
|
|
41
46
|
end
|
|
47
|
+
)
|
|
48
|
+
if #jsonRoomsOfVariant == 0 then
|
|
49
|
+
return nil
|
|
50
|
+
end
|
|
51
|
+
if #jsonRoomsOfVariant == 1 then
|
|
52
|
+
return jsonRoomsOfVariant[1]
|
|
42
53
|
end
|
|
43
|
-
return
|
|
54
|
+
return error(((("Found " .. tostring(#jsonRoomsOfVariant)) .. " JSON rooms with a variant of ") .. tostring(variant)) .. ", when there should only be 1.")
|
|
44
55
|
end
|
|
45
56
|
function ____exports.getJSONRoomsOfSubType(self, jsonRooms, subType)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
return __TS__ArrayFilter(
|
|
58
|
+
jsonRooms,
|
|
59
|
+
function(____, jsonRoom)
|
|
60
|
+
local roomSubTypeString = jsonRoom["$"].subtype
|
|
61
|
+
local roomSubType = tonumber(roomSubTypeString)
|
|
62
|
+
return roomSubType == subType
|
|
52
63
|
end
|
|
53
|
-
|
|
54
|
-
return jsonRoomsOfSubType
|
|
64
|
+
)
|
|
55
65
|
end
|
|
56
66
|
function ____exports.getRandomJSONRoom(self, jsonRooms, seed, verbose)
|
|
57
67
|
if seed == nil then
|
|
@@ -66,7 +76,7 @@ function ____exports.getRandomJSONRoom(self, jsonRooms, seed, verbose)
|
|
|
66
76
|
end
|
|
67
77
|
local chosenWeight = getRandomFloat(nil, 0, totalWeight, seed)
|
|
68
78
|
if verbose then
|
|
69
|
-
log("Randomly chose weight: " .. tostring(chosenWeight))
|
|
79
|
+
log("Randomly chose weight for JSON room: " .. tostring(chosenWeight))
|
|
70
80
|
end
|
|
71
81
|
return getJSONRoomWithChosenWeight(nil, jsonRooms, chosenWeight)
|
|
72
82
|
end
|
package/dist/functions/npc.lua
CHANGED
|
@@ -9,14 +9,12 @@ local getEntities = ____entity.getEntities
|
|
|
9
9
|
local getFilteredNewEntities = ____entity.getFilteredNewEntities
|
|
10
10
|
local getProjectiles = ____entity.getProjectiles
|
|
11
11
|
local removeEntities = ____entity.removeEntities
|
|
12
|
-
function ____exports.
|
|
13
|
-
local
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
return bosses
|
|
12
|
+
function ____exports.getAliveNPCs(self)
|
|
13
|
+
local npcs = ____exports.getNPCs(nil)
|
|
14
|
+
return __TS__ArrayFilter(
|
|
15
|
+
npcs,
|
|
16
|
+
function(____, npc) return not npc:IsDead() and not ____exports.isAliveExceptionNPC(nil, npc) end
|
|
17
|
+
)
|
|
20
18
|
end
|
|
21
19
|
function ____exports.getNPCs(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
|
|
22
20
|
if ignoreFriendly == nil then
|
|
@@ -92,22 +90,18 @@ function ____exports.fireProjectiles(self, npc, position, velocity, projectilesM
|
|
|
92
90
|
return getFilteredNewEntities(nil, oldProjectiles, newProjectiles)
|
|
93
91
|
end
|
|
94
92
|
function ____exports.getAliveBosses(self)
|
|
95
|
-
local
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
end
|
|
101
|
-
return aliveBosses
|
|
93
|
+
local aliveNPCs = ____exports.getAliveNPCs(nil)
|
|
94
|
+
return __TS__ArrayFilter(
|
|
95
|
+
aliveNPCs,
|
|
96
|
+
function(____, aliveNPC) return aliveNPC:IsBoss() end
|
|
97
|
+
)
|
|
102
98
|
end
|
|
103
|
-
function ____exports.
|
|
104
|
-
local
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
end
|
|
110
|
-
return aliveNPCs
|
|
99
|
+
function ____exports.getBosses(self)
|
|
100
|
+
local npcs = ____exports.getNPCs(nil)
|
|
101
|
+
return __TS__ArrayFilter(
|
|
102
|
+
npcs,
|
|
103
|
+
function(____, npc) return npc:IsBoss() end
|
|
104
|
+
)
|
|
111
105
|
end
|
|
112
106
|
function ____exports.removeAllNPCs(self, cap)
|
|
113
107
|
local npcs = ____exports.getNPCs(nil)
|
|
@@ -25,7 +25,7 @@ export declare function anyPlayerHasTrinket(trinketType: TrinketType | int): boo
|
|
|
25
25
|
* This function is variadic, meaning that you can supply as many characters as you want to check
|
|
26
26
|
* for. Returns true if any of the characters supplied are present.
|
|
27
27
|
*/
|
|
28
|
-
export declare function anyPlayerIs(...
|
|
28
|
+
export declare function anyPlayerIs(...matchingCharacters: PlayerType[]): boolean;
|
|
29
29
|
/**
|
|
30
30
|
* Helper function to determine if the provided character can have red heart containers. Returns
|
|
31
31
|
* true for characters like Isaac, Magdalene, or Cain. Returns true for Keeper and Tainted Keeper,
|
|
@@ -83,6 +83,8 @@ export declare function getPlayerAvailableHeartSlots(player: EntityPlayer): int;
|
|
|
83
83
|
* Kiss; use the `getPlayerMaxHeartContainers()` function for that.
|
|
84
84
|
*/
|
|
85
85
|
export declare function getCharacterMaxHeartContainers(character: PlayerType): int;
|
|
86
|
+
/** Helper function to get an array containing the characters of all of the current players. */
|
|
87
|
+
export declare function getCharacters(): number[];
|
|
86
88
|
/**
|
|
87
89
|
* Iterates over all players and checks if any are close enough to the specified position.
|
|
88
90
|
*
|
|
@@ -11,6 +11,8 @@ local LOST_STYLE_PLAYER_TYPES = ____constants.LOST_STYLE_PLAYER_TYPES
|
|
|
11
11
|
local MAX_PLAYER_HEART_CONTAINERS = ____constants.MAX_PLAYER_HEART_CONTAINERS
|
|
12
12
|
local ____HealthType = require("types.HealthType")
|
|
13
13
|
local HealthType = ____HealthType.HealthType
|
|
14
|
+
local ____array = require("functions.array")
|
|
15
|
+
local arraySum = ____array.arraySum
|
|
14
16
|
local ____bitwise = require("functions.bitwise")
|
|
15
17
|
local getKBitOfN = ____bitwise.getKBitOfN
|
|
16
18
|
local getNumBitsOfN = ____bitwise.getNumBitsOfN
|
|
@@ -29,6 +31,13 @@ function ____exports.getCharacterMaxHeartContainers(self, character)
|
|
|
29
31
|
end
|
|
30
32
|
return 12
|
|
31
33
|
end
|
|
34
|
+
function ____exports.getCharacters(self)
|
|
35
|
+
local players = ____exports.getPlayers(nil)
|
|
36
|
+
return __TS__ArrayMap(
|
|
37
|
+
players,
|
|
38
|
+
function(____, player) return player:GetPlayerType() end
|
|
39
|
+
)
|
|
40
|
+
end
|
|
32
41
|
function ____exports.getPlayerIndex(self, player)
|
|
33
42
|
local character = player:GetPlayerType()
|
|
34
43
|
local collectibleToUse = character == PlayerType.PLAYER_LAZARUS2_B and CollectibleType.COLLECTIBLE_INNER_EYE or CollectibleType.COLLECTIBLE_SAD_ONION
|
|
@@ -61,18 +70,18 @@ function ____exports.getPlayers(self, performExclusions)
|
|
|
61
70
|
do
|
|
62
71
|
local player = Isaac.GetPlayer(i)
|
|
63
72
|
if player == nil then
|
|
64
|
-
goto
|
|
73
|
+
goto __continue70
|
|
65
74
|
end
|
|
66
75
|
if ____exports.isChildPlayer(nil, player) then
|
|
67
|
-
goto
|
|
76
|
+
goto __continue70
|
|
68
77
|
end
|
|
69
78
|
local character = player:GetPlayerType()
|
|
70
79
|
if performExclusions and EXCLUDED_CHARACTERS:has(character) then
|
|
71
|
-
goto
|
|
80
|
+
goto __continue70
|
|
72
81
|
end
|
|
73
82
|
__TS__ArrayPush(players, player)
|
|
74
83
|
end
|
|
75
|
-
::
|
|
84
|
+
::__continue70::
|
|
76
85
|
i = i + 1
|
|
77
86
|
end
|
|
78
87
|
end
|
|
@@ -99,39 +108,34 @@ function ____exports.addTrinketCostume(self, player, trinketType)
|
|
|
99
108
|
player:AddCostume(itemConfigTrinket, false)
|
|
100
109
|
end
|
|
101
110
|
function ____exports.anyPlayerCloserThan(self, position, distance)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
return false
|
|
111
|
+
local players = ____exports.getPlayers(nil)
|
|
112
|
+
return __TS__ArraySome(
|
|
113
|
+
players,
|
|
114
|
+
function(____, player) return player.Position:Distance(position) <= distance end
|
|
115
|
+
)
|
|
108
116
|
end
|
|
109
117
|
function ____exports.anyPlayerHasCollectible(self, collectibleType)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
return false
|
|
118
|
+
local players = ____exports.getPlayers(nil)
|
|
119
|
+
return __TS__ArraySome(
|
|
120
|
+
players,
|
|
121
|
+
function(____, player) return player:HasCollectible(collectibleType) end
|
|
122
|
+
)
|
|
116
123
|
end
|
|
117
124
|
function ____exports.anyPlayerHasTrinket(self, trinketType)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
return false
|
|
125
|
+
local players = ____exports.getPlayers(nil)
|
|
126
|
+
return __TS__ArraySome(
|
|
127
|
+
players,
|
|
128
|
+
function(____, player) return player:HasTrinket(trinketType) end
|
|
129
|
+
)
|
|
124
130
|
end
|
|
125
131
|
function ____exports.anyPlayerIs(self, ...)
|
|
126
|
-
local
|
|
127
|
-
local
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
end
|
|
134
|
-
return false
|
|
132
|
+
local matchingCharacters = {...}
|
|
133
|
+
local matchingCharacterSet = __TS__New(Set, matchingCharacters)
|
|
134
|
+
local characters = ____exports.getCharacters(nil)
|
|
135
|
+
return __TS__ArraySome(
|
|
136
|
+
characters,
|
|
137
|
+
function(____, character) return matchingCharacterSet:has(character) end
|
|
138
|
+
)
|
|
135
139
|
end
|
|
136
140
|
function ____exports.characterCanHaveRedHearts(self, character)
|
|
137
141
|
return not CHARACTERS_WITH_NO_RED_HEARTS:has(character)
|
|
@@ -282,14 +286,14 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
|
|
|
282
286
|
do
|
|
283
287
|
local player = Isaac.GetPlayer(i)
|
|
284
288
|
if player == nil then
|
|
285
|
-
goto
|
|
289
|
+
goto __continue62
|
|
286
290
|
end
|
|
287
291
|
local playerHash = GetPtrHash(player)
|
|
288
292
|
if playerHash == playerToFindHash then
|
|
289
293
|
return i
|
|
290
294
|
end
|
|
291
295
|
end
|
|
292
|
-
::
|
|
296
|
+
::__continue62::
|
|
293
297
|
i = i + 1
|
|
294
298
|
end
|
|
295
299
|
end
|
|
@@ -306,14 +310,14 @@ end
|
|
|
306
310
|
function ____exports.getPlayersOfType(self, ...)
|
|
307
311
|
local characters = {...}
|
|
308
312
|
local charactersSet = __TS__New(Set, characters)
|
|
309
|
-
local players =
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
313
|
+
local players = ____exports.getPlayers(nil)
|
|
314
|
+
return __TS__ArrayFilter(
|
|
315
|
+
players,
|
|
316
|
+
function(____, player)
|
|
317
|
+
local character = player:GetPlayerType()
|
|
318
|
+
return charactersSet:has(character)
|
|
314
319
|
end
|
|
315
|
-
|
|
316
|
-
return players
|
|
320
|
+
)
|
|
317
321
|
end
|
|
318
322
|
function ____exports.getTotalCharge(self, player, activeSlot)
|
|
319
323
|
local activeCharge = player:GetActiveCharge(activeSlot)
|
|
@@ -321,11 +325,12 @@ function ____exports.getTotalCharge(self, player, activeSlot)
|
|
|
321
325
|
return activeCharge + batteryCharge
|
|
322
326
|
end
|
|
323
327
|
function ____exports.getTotalPlayerCollectibles(self, collectibleType)
|
|
324
|
-
local
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
328
|
+
local players = ____exports.getPlayers(nil)
|
|
329
|
+
local numCollectiblesArray = __TS__ArrayMap(
|
|
330
|
+
players,
|
|
331
|
+
function(____, player) return player:GetCollectibleNum(collectibleType) end
|
|
332
|
+
)
|
|
333
|
+
return arraySum(nil, numCollectiblesArray)
|
|
329
334
|
end
|
|
330
335
|
function ____exports.hasLostCurse(self, player)
|
|
331
336
|
local effects = player:GetEffects()
|
|
@@ -450,9 +455,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
450
455
|
itemPool:RemoveCollectible(collectibleType)
|
|
451
456
|
end
|
|
452
457
|
repeat
|
|
453
|
-
local
|
|
454
|
-
local
|
|
455
|
-
if
|
|
458
|
+
local ____switch109 = activeSlot
|
|
459
|
+
local ____cond109 = ____switch109 == ActiveSlot.SLOT_PRIMARY
|
|
460
|
+
if ____cond109 then
|
|
456
461
|
do
|
|
457
462
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
458
463
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -461,8 +466,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
461
466
|
break
|
|
462
467
|
end
|
|
463
468
|
end
|
|
464
|
-
|
|
465
|
-
if
|
|
469
|
+
____cond109 = ____cond109 or ____switch109 == ActiveSlot.SLOT_SECONDARY
|
|
470
|
+
if ____cond109 then
|
|
466
471
|
do
|
|
467
472
|
if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
|
|
468
473
|
player:RemoveCollectible(primaryCollectibleType)
|
|
@@ -477,16 +482,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
|
|
|
477
482
|
break
|
|
478
483
|
end
|
|
479
484
|
end
|
|
480
|
-
|
|
481
|
-
if
|
|
485
|
+
____cond109 = ____cond109 or ____switch109 == ActiveSlot.SLOT_POCKET
|
|
486
|
+
if ____cond109 then
|
|
482
487
|
do
|
|
483
488
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
484
489
|
player:SetActiveCharge(charge, activeSlot)
|
|
485
490
|
break
|
|
486
491
|
end
|
|
487
492
|
end
|
|
488
|
-
|
|
489
|
-
if
|
|
493
|
+
____cond109 = ____cond109 or ____switch109 == ActiveSlot.SLOT_POCKET2
|
|
494
|
+
if ____cond109 then
|
|
490
495
|
do
|
|
491
496
|
player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
|
|
492
497
|
break
|
package/dist/functions/util.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
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;
|
|
3
10
|
/**
|
|
4
11
|
* Using a Map constructor to copy a Map does not seem to work properly, so use this helper function
|
|
5
12
|
* instead.
|
|
@@ -10,6 +17,12 @@ export declare function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V>;
|
|
|
10
17
|
* instead.
|
|
11
18
|
*/
|
|
12
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>;
|
|
13
26
|
/**
|
|
14
27
|
* Helper function to get type safety on a switch statement.
|
|
15
28
|
* Very useful to be future-safe against people adding values to a type or an enum.
|
package/dist/functions/util.lua
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
require("lualib_bundle");
|
|
3
3
|
local ____exports = {}
|
|
4
4
|
local HEX_STRING_LENGTH = 6
|
|
5
|
+
function ____exports.addSetsToSet(self, mainSet, ...)
|
|
6
|
+
local setsToAdd = {...}
|
|
7
|
+
for ____, set in ipairs(setsToAdd) do
|
|
8
|
+
for ____, value in __TS__Iterator(set:values()) do
|
|
9
|
+
mainSet:add(value)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
5
13
|
function ____exports.copyMap(self, oldMap)
|
|
6
14
|
local newMap = __TS__New(Map)
|
|
7
15
|
for ____, ____value in __TS__Iterator(oldMap:entries()) do
|
|
@@ -18,6 +26,16 @@ function ____exports.copySet(self, oldSet)
|
|
|
18
26
|
end
|
|
19
27
|
return newSet
|
|
20
28
|
end
|
|
29
|
+
function ____exports.combineSets(self, ...)
|
|
30
|
+
local sets = {...}
|
|
31
|
+
local newSet = __TS__New(Set)
|
|
32
|
+
for ____, set in ipairs(sets) do
|
|
33
|
+
for ____, value in __TS__Iterator(set:values()) do
|
|
34
|
+
newSet:add(value)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
return newSet
|
|
38
|
+
end
|
|
21
39
|
____exports.ensureAllCases = function(____, obj) return obj end
|
|
22
40
|
function ____exports.getEnumValues(self, transpiledEnum)
|
|
23
41
|
local enumValues = {}
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export * from "./functions/doors";
|
|
|
23
23
|
export * from "./functions/entity";
|
|
24
24
|
export * from "./functions/familiars";
|
|
25
25
|
export * from "./functions/flag";
|
|
26
|
+
export * from "./functions/globals";
|
|
26
27
|
export * from "./functions/gridEntity";
|
|
27
28
|
export * from "./functions/input";
|
|
28
29
|
export * from "./functions/json";
|
package/dist/index.lua
CHANGED
|
@@ -190,6 +190,14 @@ do
|
|
|
190
190
|
end
|
|
191
191
|
end
|
|
192
192
|
end
|
|
193
|
+
do
|
|
194
|
+
local ____export = require("functions.globals")
|
|
195
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
196
|
+
if ____exportKey ~= "default" then
|
|
197
|
+
____exports[____exportKey] = ____exportValue
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
193
201
|
do
|
|
194
202
|
local ____export = require("functions.gridEntity")
|
|
195
203
|
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.0.
|
|
3
|
+
"version": "1.0.605",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist/**/*.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^1.0.
|
|
28
|
+
"isaac-typescript-definitions": "^1.0.333",
|
|
29
29
|
"isaacscript-lint": "^1.0.79",
|
|
30
30
|
"isaacscript-tsconfig": "^1.1.8",
|
|
31
31
|
"typedoc": "^0.22.11",
|