isaacscript-common 1.2.67 → 1.2.70
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/collectibleCacheFlag.lua +3 -3
- package/dist/functions/collectibleSet.lua +3 -3
- package/dist/functions/collectibles.d.ts +1 -1
- package/dist/functions/collectibles.lua +1 -1
- package/dist/functions/doors.d.ts +8 -0
- package/dist/functions/doors.lua +17 -23
- package/dist/functions/transformations.lua +3 -3
- package/dist/functions/utils.d.ts +4 -0
- package/dist/functions/utils.lua +9 -0
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ local __TS__Iterator = ____lualib.__TS__Iterator
|
|
|
8
8
|
local ____exports = {}
|
|
9
9
|
local ____collectibles = require("functions.collectibles")
|
|
10
10
|
local collectibleHasCacheFlag = ____collectibles.collectibleHasCacheFlag
|
|
11
|
-
local
|
|
11
|
+
local getMaxCollectibleType = ____collectibles.getMaxCollectibleType
|
|
12
12
|
local ____math = require("functions.math")
|
|
13
13
|
local range = ____math.range
|
|
14
14
|
local ____set = require("functions.set")
|
|
@@ -17,10 +17,10 @@ local ____utils = require("functions.utils")
|
|
|
17
17
|
local getEnumValues = ____utils.getEnumValues
|
|
18
18
|
local CACHE_FLAG_TO_COLLECTIBLES_MAP = __TS__New(Map)
|
|
19
19
|
local function initCacheFlagMap(self)
|
|
20
|
-
local
|
|
20
|
+
local maxCollectibleType = getMaxCollectibleType(nil)
|
|
21
21
|
for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
|
|
22
22
|
local collectiblesSet = __TS__New(Set)
|
|
23
|
-
for ____, collectibleType in ipairs(range(nil, 1,
|
|
23
|
+
for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleType)) do
|
|
24
24
|
if collectibleHasCacheFlag(nil, collectibleType, cacheFlag) then
|
|
25
25
|
collectiblesSet:add(collectibleType)
|
|
26
26
|
end
|
|
@@ -4,7 +4,7 @@ local Set = ____lualib.Set
|
|
|
4
4
|
local __TS__New = ____lualib.__TS__New
|
|
5
5
|
local ____exports = {}
|
|
6
6
|
local ____collectibles = require("functions.collectibles")
|
|
7
|
-
local
|
|
7
|
+
local getMaxCollectibleType = ____collectibles.getMaxCollectibleType
|
|
8
8
|
local ____math = require("functions.math")
|
|
9
9
|
local range = ____math.range
|
|
10
10
|
local ____set = require("functions.set")
|
|
@@ -12,8 +12,8 @@ local copySet = ____set.copySet
|
|
|
12
12
|
local COLLECTIBLE_SET = __TS__New(Set)
|
|
13
13
|
local function initCollectibleSet(self)
|
|
14
14
|
local itemConfig = Isaac.GetItemConfig()
|
|
15
|
-
local
|
|
16
|
-
for ____, collectibleType in ipairs(range(nil, 1,
|
|
15
|
+
local maxCollectibleType = getMaxCollectibleType(nil)
|
|
16
|
+
for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleType)) do
|
|
17
17
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
18
18
|
if itemConfigItem ~= nil then
|
|
19
19
|
COLLECTIBLE_SET:add(collectibleType)
|
|
@@ -49,7 +49,7 @@ export declare function getCollectibleMaxCharges(collectibleType: CollectibleTyp
|
|
|
49
49
|
export declare function getCollectibleName(collectibleType: CollectibleType | int): string;
|
|
50
50
|
/** Helper function to get all of the collectible entities in the room. */
|
|
51
51
|
export declare function getCollectibles(matchingSubType?: number): EntityPickup[];
|
|
52
|
-
export declare function
|
|
52
|
+
export declare function getMaxCollectibleType(): int;
|
|
53
53
|
/**
|
|
54
54
|
* Returns whether or not the given collectible is a "glitched" item. All items are replaced by
|
|
55
55
|
* glitched items once a player has TMTRAINER. However, glitched items can also "naturally" appear
|
|
@@ -141,7 +141,7 @@ function ____exports.getCollectibles(self, matchingSubType)
|
|
|
141
141
|
end
|
|
142
142
|
return getPickups(nil, PickupVariant.PICKUP_COLLECTIBLE, matchingSubType)
|
|
143
143
|
end
|
|
144
|
-
function ____exports.
|
|
144
|
+
function ____exports.getMaxCollectibleType(self)
|
|
145
145
|
local itemConfig = Isaac.GetItemConfig()
|
|
146
146
|
return itemConfig:GetCollectibles().Size - 1
|
|
147
147
|
end
|
|
@@ -88,3 +88,11 @@ export declare function openDoorFast(door: GridEntityDoor): void;
|
|
|
88
88
|
* @returns The number of doors removed.
|
|
89
89
|
*/
|
|
90
90
|
export declare function removeAllDoors(...roomTypes: RoomType[]): int;
|
|
91
|
+
/** Helper function to remove a single door. */
|
|
92
|
+
export declare function removeDoor(door: GridEntityDoor): void;
|
|
93
|
+
/**
|
|
94
|
+
* Helper function to remove the doors provided.
|
|
95
|
+
*
|
|
96
|
+
* This function is variadic, meaning that you can specify as many doors as you want to remove.
|
|
97
|
+
*/
|
|
98
|
+
export declare function removeDoors(...doors: GridEntityDoor[]): void;
|
package/dist/functions/doors.lua
CHANGED
|
@@ -40,6 +40,17 @@ function ____exports.isSecretRoomDoor(self, door)
|
|
|
40
40
|
local filename = sprite:GetFilename()
|
|
41
41
|
return filename == "gfx/grid/Door_08_HoleInWall.anm2"
|
|
42
42
|
end
|
|
43
|
+
function ____exports.removeDoor(self, door)
|
|
44
|
+
local game = Game()
|
|
45
|
+
local room = game:GetRoom()
|
|
46
|
+
room:RemoveDoor(door.Slot)
|
|
47
|
+
end
|
|
48
|
+
function ____exports.removeDoors(self, ...)
|
|
49
|
+
local doors = {...}
|
|
50
|
+
for ____, door in ipairs(doors) do
|
|
51
|
+
____exports.removeDoor(nil, door)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
43
54
|
function ____exports.closeAllDoors(self)
|
|
44
55
|
for ____, door in ipairs(____exports.getDoors(nil)) do
|
|
45
56
|
door:Close(true)
|
|
@@ -167,28 +178,11 @@ function ____exports.openDoorFast(self, door)
|
|
|
167
178
|
sprite:Play("Opened", true)
|
|
168
179
|
end
|
|
169
180
|
function ____exports.removeAllDoors(self, ...)
|
|
170
|
-
local
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
local i = 0
|
|
177
|
-
while i < MAX_NUM_DOORS do
|
|
178
|
-
do
|
|
179
|
-
local door = room:GetDoor(i)
|
|
180
|
-
if door == nil then
|
|
181
|
-
goto __continue38
|
|
182
|
-
end
|
|
183
|
-
if #roomTypes == 0 or roomTypesSet:has(door.TargetRoomType) then
|
|
184
|
-
room:RemoveDoor(i)
|
|
185
|
-
numDoorsRemoved = numDoorsRemoved + 1
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
::__continue38::
|
|
189
|
-
i = i + 1
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
return numDoorsRemoved
|
|
181
|
+
local doors = ____exports.getDoors(nil, ...)
|
|
182
|
+
____exports.removeDoors(
|
|
183
|
+
nil,
|
|
184
|
+
table.unpack(doors)
|
|
185
|
+
)
|
|
186
|
+
return #doors
|
|
193
187
|
end
|
|
194
188
|
return ____exports
|
|
@@ -9,7 +9,7 @@ local ____transformationNameMap = require("maps.transformationNameMap")
|
|
|
9
9
|
local TRANSFORMATION_NAME_MAP = ____transformationNameMap.TRANSFORMATION_NAME_MAP
|
|
10
10
|
local ____collectibles = require("functions.collectibles")
|
|
11
11
|
local collectibleHasTag = ____collectibles.collectibleHasTag
|
|
12
|
-
local
|
|
12
|
+
local getMaxCollectibleType = ____collectibles.getMaxCollectibleType
|
|
13
13
|
local ____math = require("functions.math")
|
|
14
14
|
local range = ____math.range
|
|
15
15
|
local ____set = require("functions.set")
|
|
@@ -33,14 +33,14 @@ local TRANSFORMATIONS_THAT_GRANT_FLYING = __TS__New(Set, {PlayerForm.PLAYERFORM_
|
|
|
33
33
|
local TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP = __TS__New(Map)
|
|
34
34
|
local COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP = __TS__New(Map)
|
|
35
35
|
local function initMaps(self)
|
|
36
|
-
local
|
|
36
|
+
local maxCollectibleType = getMaxCollectibleType(nil)
|
|
37
37
|
for ____, playerForm in __TS__Iterator(TRANSFORMATION_TO_TAG_MAP:keys()) do
|
|
38
38
|
TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:set(
|
|
39
39
|
playerForm,
|
|
40
40
|
__TS__New(Set)
|
|
41
41
|
)
|
|
42
42
|
end
|
|
43
|
-
for ____, collectibleType in ipairs(range(nil, 1,
|
|
43
|
+
for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleType)) do
|
|
44
44
|
for ____, ____value in __TS__Iterator(TRANSFORMATION_TO_TAG_MAP:entries()) do
|
|
45
45
|
local playerForm = ____value[1]
|
|
46
46
|
local tag = ____value[2]
|
|
@@ -80,3 +80,7 @@ export declare function onSetSeed(): boolean;
|
|
|
80
80
|
* message (which `Isaac.ConsoleOutput()` does not do by default).
|
|
81
81
|
*/
|
|
82
82
|
export declare function printConsole(msg: string): void;
|
|
83
|
+
/**
|
|
84
|
+
* Helper function to repeat code N times. This is faster to type and cleaner than using a for loop.
|
|
85
|
+
*/
|
|
86
|
+
export declare function repeat(n: int, func: () => void): void;
|
package/dist/functions/utils.lua
CHANGED
|
@@ -53,4 +53,13 @@ end
|
|
|
53
53
|
function ____exports.printConsole(self, msg)
|
|
54
54
|
Isaac.ConsoleOutput(msg .. "\n")
|
|
55
55
|
end
|
|
56
|
+
____exports["repeat"] = function(self, n, func)
|
|
57
|
+
do
|
|
58
|
+
local i = 0
|
|
59
|
+
while i < n do
|
|
60
|
+
func(nil)
|
|
61
|
+
i = i + 1
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
56
65
|
return ____exports
|