isaacscript-common 4.3.2 → 4.5.0
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/functions/minimap.d.ts +32 -0
- package/functions/minimap.lua +65 -0
- package/functions/nextStage.d.ts +1 -1
- package/functions/nextStage.lua +7 -1
- package/functions/rooms.d.ts +13 -3
- package/functions/rooms.lua +22 -5
- package/functions/stage.d.ts +10 -0
- package/functions/stage.lua +20 -0
- package/index.d.ts +1 -0
- package/index.lua +8 -0
- package/objects/stageTypeSuffixes.d.ts +4 -0
- package/objects/stageTypeSuffixes.lua +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DisplayFlag } from "isaac-typescript-definitions";
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to get the minimap `DisplayFlag` value for every room on the floor. Returns a map
|
|
4
|
+
* that is indexed by the room's safe grid index.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getFloorDisplayFlags(): Map<int, BitFlags<DisplayFlag>>;
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to get a particular room's minimap display flags (e.g. whether or not it is
|
|
9
|
+
* visible and so on).
|
|
10
|
+
*
|
|
11
|
+
* @param roomGridIndex Optional. Default is the current room index.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getRoomDisplayFlags(roomGridIndex?: int): BitFlags<DisplayFlag>;
|
|
14
|
+
/**
|
|
15
|
+
* Helper function to set the minimap `DisplayFlag` value for multiple rooms at once.
|
|
16
|
+
*
|
|
17
|
+
* This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
|
|
18
|
+
* the changes will be immediately visible.
|
|
19
|
+
*
|
|
20
|
+
* @param displayFlagsMap A map of the display flags that is indexed by the room's safe grid index.
|
|
21
|
+
*/
|
|
22
|
+
export declare function setDisplayFlags(displayFlagsMap: Map<int, BitFlags<DisplayFlag>>): void;
|
|
23
|
+
/** Alias for the `setDisplayFlags` function. */
|
|
24
|
+
export declare function setFloorDisplayFlags(displayFlagsMap: Map<int, BitFlags<DisplayFlag>>): void;
|
|
25
|
+
/**
|
|
26
|
+
* Helper function to set a particular room's minimap display flags (e.g. whether or not it is
|
|
27
|
+
* visible and so on).
|
|
28
|
+
*
|
|
29
|
+
* @param roomGridIndex Set to undefined to use the current room index.
|
|
30
|
+
* @param displayFlags The bit flags value to set. (See the `DisplayFlag` enum.)
|
|
31
|
+
*/
|
|
32
|
+
export declare function setRoomDisplayFlags(roomGridIndex: int | undefined, displayFlags: BitFlags<DisplayFlag>): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Map = ____lualib.Map
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local ____cachedClasses = require("cachedClasses")
|
|
7
|
+
local game = ____cachedClasses.game
|
|
8
|
+
local ____roomData = require("functions.roomData")
|
|
9
|
+
local getRoomDescriptor = ____roomData.getRoomDescriptor
|
|
10
|
+
local ____rooms = require("functions.rooms")
|
|
11
|
+
local getRoomsInGrid = ____rooms.getRoomsInGrid
|
|
12
|
+
--- Helper function to set a particular room's minimap display flags (e.g. whether or not it is
|
|
13
|
+
-- visible and so on).
|
|
14
|
+
--
|
|
15
|
+
-- @param roomGridIndex Set to undefined to use the current room index.
|
|
16
|
+
-- @param displayFlags The bit flags value to set. (See the `DisplayFlag` enum.)
|
|
17
|
+
function ____exports.setRoomDisplayFlags(self, roomGridIndex, displayFlags)
|
|
18
|
+
local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
|
|
19
|
+
roomDescriptor.DisplayFlags = displayFlags
|
|
20
|
+
end
|
|
21
|
+
--- Helper function to get the minimap `DisplayFlag` value for every room on the floor. Returns a map
|
|
22
|
+
-- that is indexed by the room's safe grid index.
|
|
23
|
+
function ____exports.getFloorDisplayFlags(self)
|
|
24
|
+
local displayFlagsMap = __TS__New(Map)
|
|
25
|
+
local roomsInGrid = getRoomsInGrid(nil)
|
|
26
|
+
for ____, roomDescriptor in ipairs(roomsInGrid) do
|
|
27
|
+
displayFlagsMap:set(roomDescriptor.SafeGridIndex, roomDescriptor.DisplayFlags)
|
|
28
|
+
end
|
|
29
|
+
return displayFlagsMap
|
|
30
|
+
end
|
|
31
|
+
--- Helper function to get a particular room's minimap display flags (e.g. whether or not it is
|
|
32
|
+
-- visible and so on).
|
|
33
|
+
--
|
|
34
|
+
-- @param roomGridIndex Optional. Default is the current room index.
|
|
35
|
+
function ____exports.getRoomDisplayFlags(self, roomGridIndex)
|
|
36
|
+
local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
|
|
37
|
+
return roomDescriptor.DisplayFlags
|
|
38
|
+
end
|
|
39
|
+
--- Helper function to set the minimap `DisplayFlag` value for multiple rooms at once.
|
|
40
|
+
--
|
|
41
|
+
-- This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
|
|
42
|
+
-- the changes will be immediately visible.
|
|
43
|
+
--
|
|
44
|
+
-- @param displayFlagsMap A map of the display flags that is indexed by the room's safe grid index.
|
|
45
|
+
function ____exports.setDisplayFlags(self, displayFlagsMap)
|
|
46
|
+
local level = game:GetLevel()
|
|
47
|
+
for ____, ____value in __TS__Iterator(displayFlagsMap:entries()) do
|
|
48
|
+
local roomGridIndex = ____value[1]
|
|
49
|
+
local displayFlags = ____value[2]
|
|
50
|
+
if MinimapAPI == nil then
|
|
51
|
+
____exports.setRoomDisplayFlags(nil, roomGridIndex, displayFlags)
|
|
52
|
+
else
|
|
53
|
+
local roomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
|
|
54
|
+
if roomDescriptor ~= nil then
|
|
55
|
+
roomDescriptor.DisplayFlags = displayFlags
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
level:UpdateVisibility()
|
|
60
|
+
end
|
|
61
|
+
--- Alias for the `setDisplayFlags` function.
|
|
62
|
+
function ____exports.setFloorDisplayFlags(self, displayFlagsMap)
|
|
63
|
+
____exports.setDisplayFlags(nil, displayFlagsMap)
|
|
64
|
+
end
|
|
65
|
+
return ____exports
|
package/functions/nextStage.d.ts
CHANGED
|
@@ -13,6 +13,6 @@ export declare function getNextStage(): LevelStage;
|
|
|
13
13
|
* based on the current stage, room, and game state flags.
|
|
14
14
|
*
|
|
15
15
|
* @param upwards Whether or not the player should go up to Cathedral in the case of being on Womb
|
|
16
|
-
* 2.
|
|
16
|
+
* 2. Default is false.
|
|
17
17
|
*/
|
|
18
18
|
export declare function getNextStageType(upwards?: boolean): StageType;
|
package/functions/nextStage.lua
CHANGED
|
@@ -200,7 +200,7 @@ end
|
|
|
200
200
|
-- based on the current stage, room, and game state flags.
|
|
201
201
|
--
|
|
202
202
|
-- @param upwards Whether or not the player should go up to Cathedral in the case of being on Womb
|
|
203
|
-
-- 2.
|
|
203
|
+
-- 2. Default is false.
|
|
204
204
|
function ____exports.getNextStageType(self, upwards)
|
|
205
205
|
if upwards == nil then
|
|
206
206
|
upwards = false
|
|
@@ -240,6 +240,12 @@ function ____exports.getNextStageType(self, upwards)
|
|
|
240
240
|
end
|
|
241
241
|
return StageType.WRATH_OF_THE_LAMB
|
|
242
242
|
end
|
|
243
|
+
if nextStage == LevelStage.THE_VOID then
|
|
244
|
+
return StageType.ORIGINAL
|
|
245
|
+
end
|
|
246
|
+
if nextStage == LevelStage.HOME then
|
|
247
|
+
return StageType.ORIGINAL
|
|
248
|
+
end
|
|
243
249
|
return calculateStageType(nil, nextStage)
|
|
244
250
|
end
|
|
245
251
|
return ____exports
|
package/functions/rooms.d.ts
CHANGED
|
@@ -49,15 +49,25 @@ export declare function getRoomShapeNeighborGridIndexDeltas(roomShape: RoomShape
|
|
|
49
49
|
*/
|
|
50
50
|
export declare function getRoomTypeName(roomType: RoomType): string;
|
|
51
51
|
/**
|
|
52
|
-
* Helper function to get the room descriptor for every room on the level
|
|
53
|
-
* method to accomplish this. Rooms without data are assumed to be
|
|
54
|
-
* the list.
|
|
52
|
+
* Helper function to get the room descriptor for every room on the level, including off-grid rooms.
|
|
53
|
+
* Uses the `Level.GetRooms` method to accomplish this. Rooms without data are assumed to be
|
|
54
|
+
* non-existent and are not added to the list.
|
|
55
55
|
*
|
|
56
56
|
* @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
|
|
57
57
|
* extra-dimensional rooms are automatically be generated and can be
|
|
58
58
|
* seen when you iterate over the `RoomList`. Default is false.
|
|
59
59
|
*/
|
|
60
60
|
export declare function getRooms(includeExtraDimensionalRooms?: boolean): RoomDescriptor[];
|
|
61
|
+
/**
|
|
62
|
+
* Helper function to get the room descriptor for every room on the level except for rooms that are
|
|
63
|
+
* not on the grid. Uses the `Level.GetRooms` method to accomplish this. Rooms without data are
|
|
64
|
+
* assumed to be non-existent and are not added to the list.
|
|
65
|
+
*
|
|
66
|
+
* @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
|
|
67
|
+
* extra-dimensional rooms are automatically be generated and can be
|
|
68
|
+
* seen when you iterate over the `RoomList`. Default is false.
|
|
69
|
+
*/
|
|
70
|
+
export declare function getRoomsInGrid(includeExtraDimensionalRooms?: boolean): RoomDescriptor[];
|
|
61
71
|
/**
|
|
62
72
|
* Helper function to get the room descriptor for every room on the level in a specific dimension.
|
|
63
73
|
* Uses the `Level.GetRooms` method to accomplish this. Rooms without data are assumed to be
|
package/functions/rooms.lua
CHANGED
|
@@ -67,9 +67,9 @@ local irange = ____utils.irange
|
|
|
67
67
|
function ____exports.getRoomShapeNeighborGridIndexDeltas(self, roomShape)
|
|
68
68
|
return {__TS__Spread(ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA[roomShape]:values())}
|
|
69
69
|
end
|
|
70
|
-
--- Helper function to get the room descriptor for every room on the level
|
|
71
|
-
-- method to accomplish this. Rooms without data are assumed to be
|
|
72
|
-
-- the list.
|
|
70
|
+
--- Helper function to get the room descriptor for every room on the level, including off-grid rooms.
|
|
71
|
+
-- Uses the `Level.GetRooms` method to accomplish this. Rooms without data are assumed to be
|
|
72
|
+
-- non-existent and are not added to the list.
|
|
73
73
|
--
|
|
74
74
|
-- @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
|
|
75
75
|
-- extra-dimensional rooms are automatically be generated and can be
|
|
@@ -209,6 +209,23 @@ end
|
|
|
209
209
|
function ____exports.getRoomTypeName(self, roomType)
|
|
210
210
|
return ROOM_TYPE_NAMES[roomType]
|
|
211
211
|
end
|
|
212
|
+
--- Helper function to get the room descriptor for every room on the level except for rooms that are
|
|
213
|
+
-- not on the grid. Uses the `Level.GetRooms` method to accomplish this. Rooms without data are
|
|
214
|
+
-- assumed to be non-existent and are not added to the list.
|
|
215
|
+
--
|
|
216
|
+
-- @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
|
|
217
|
+
-- extra-dimensional rooms are automatically be generated and can be
|
|
218
|
+
-- seen when you iterate over the `RoomList`. Default is false.
|
|
219
|
+
function ____exports.getRoomsInGrid(self, includeExtraDimensionalRooms)
|
|
220
|
+
if includeExtraDimensionalRooms == nil then
|
|
221
|
+
includeExtraDimensionalRooms = false
|
|
222
|
+
end
|
|
223
|
+
local rooms = ____exports.getRooms(nil, includeExtraDimensionalRooms)
|
|
224
|
+
return __TS__ArrayFilter(
|
|
225
|
+
rooms,
|
|
226
|
+
function(____, roomDescriptor) return roomDescriptor.SafeGridIndex >= 0 end
|
|
227
|
+
)
|
|
228
|
+
end
|
|
212
229
|
--- Helper function to get the room descriptor for every room on the level in a specific dimension.
|
|
213
230
|
-- Uses the `Level.GetRooms` method to accomplish this. Rooms without data are assumed to be
|
|
214
231
|
-- non-existent and are not added to the list.
|
|
@@ -430,12 +447,12 @@ function ____exports.setRoomCleared(self)
|
|
|
430
447
|
for ____, door in ipairs(getDoors(nil)) do
|
|
431
448
|
do
|
|
432
449
|
if isHiddenSecretRoomDoor(nil, door) then
|
|
433
|
-
goto
|
|
450
|
+
goto __continue69
|
|
434
451
|
end
|
|
435
452
|
openDoorFast(nil, door)
|
|
436
453
|
door.ExtraVisible = false
|
|
437
454
|
end
|
|
438
|
-
::
|
|
455
|
+
::__continue69::
|
|
439
456
|
end
|
|
440
457
|
sfxManager:Stop(SoundEffect.DOOR_HEAVY_OPEN)
|
|
441
458
|
game:ShakeScreen(0)
|
package/functions/stage.d.ts
CHANGED
|
@@ -36,6 +36,16 @@ export declare function onDarkRoom(): boolean;
|
|
|
36
36
|
export declare function onFinalFloor(): boolean;
|
|
37
37
|
export declare function onRepentanceStage(): boolean;
|
|
38
38
|
export declare function onSheol(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Helper function to warp to a new stage/level.
|
|
41
|
+
*
|
|
42
|
+
* @param stage The stage number to warp to.
|
|
43
|
+
* @param stageType The stage type to warp to.
|
|
44
|
+
* @param reseed Optional. Whether or not to reseed the floor upon arrival. Default is false. Set
|
|
45
|
+
* this to true if you are warping to the same stage but a different stage type (or
|
|
46
|
+
* else the floor layout will be identical to the old floor).
|
|
47
|
+
*/
|
|
48
|
+
export declare function setStage(stage: LevelStage, stageType: StageType, reseed?: boolean): void;
|
|
39
49
|
/**
|
|
40
50
|
* Helper function to convert a numerical `StageType` into the letter suffix supplied to the "stage"
|
|
41
51
|
* console command. For example, `StageType.REPENTANCE` is the stage type for Downpour, and the
|
package/functions/stage.lua
CHANGED
|
@@ -4,6 +4,8 @@ local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
|
|
|
4
4
|
local StageType = ____isaac_2Dtypescript_2Ddefinitions.StageType
|
|
5
5
|
local ____cachedClasses = require("cachedClasses")
|
|
6
6
|
local game = ____cachedClasses.game
|
|
7
|
+
local ____stageTypeSuffixes = require("objects.stageTypeSuffixes")
|
|
8
|
+
local STAGE_TYPE_SUFFIXES = ____stageTypeSuffixes.STAGE_TYPE_SUFFIXES
|
|
7
9
|
local ____stageTypeToLetter = require("objects.stageTypeToLetter")
|
|
8
10
|
local STAGE_TYPE_TO_LETTER = ____stageTypeToLetter.STAGE_TYPE_TO_LETTER
|
|
9
11
|
function ____exports.isRepentanceStage(self, stageType)
|
|
@@ -111,4 +113,22 @@ function ____exports.onSheol(self)
|
|
|
111
113
|
local stageType = level:GetStageType()
|
|
112
114
|
return stage == LevelStage.SHEOL_CATHEDRAL and stageType == StageType.ORIGINAL
|
|
113
115
|
end
|
|
116
|
+
--- Helper function to warp to a new stage/level.
|
|
117
|
+
--
|
|
118
|
+
-- @param stage The stage number to warp to.
|
|
119
|
+
-- @param stageType The stage type to warp to.
|
|
120
|
+
-- @param reseed Optional. Whether or not to reseed the floor upon arrival. Default is false. Set
|
|
121
|
+
-- this to true if you are warping to the same stage but a different stage type (or
|
|
122
|
+
-- else the floor layout will be identical to the old floor).
|
|
123
|
+
function ____exports.setStage(self, stage, stageType, reseed)
|
|
124
|
+
if reseed == nil then
|
|
125
|
+
reseed = false
|
|
126
|
+
end
|
|
127
|
+
local stageTypeSuffix = STAGE_TYPE_SUFFIXES[stageType]
|
|
128
|
+
local command = ("stage " .. tostring(stage)) .. stageTypeSuffix
|
|
129
|
+
Isaac.ExecuteCommand(command)
|
|
130
|
+
if reseed then
|
|
131
|
+
Isaac.ExecuteCommand("reseed")
|
|
132
|
+
end
|
|
133
|
+
end
|
|
114
134
|
return ____exports
|
package/index.d.ts
CHANGED
|
@@ -77,6 +77,7 @@ export * from "./functions/log";
|
|
|
77
77
|
export * from "./functions/map";
|
|
78
78
|
export * from "./functions/math";
|
|
79
79
|
export * from "./functions/mergeTests";
|
|
80
|
+
export * from "./functions/minimap";
|
|
80
81
|
export * from "./functions/nextStage";
|
|
81
82
|
export * from "./functions/npc";
|
|
82
83
|
export * from "./functions/pickups";
|
package/index.lua
CHANGED
|
@@ -612,6 +612,14 @@ do
|
|
|
612
612
|
end
|
|
613
613
|
end
|
|
614
614
|
end
|
|
615
|
+
do
|
|
616
|
+
local ____export = require("functions.minimap")
|
|
617
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
618
|
+
if ____exportKey ~= "default" then
|
|
619
|
+
____exports[____exportKey] = ____exportValue
|
|
620
|
+
end
|
|
621
|
+
end
|
|
622
|
+
end
|
|
615
623
|
do
|
|
616
624
|
local ____export = require("functions.nextStage")
|
|
617
625
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
3
|
+
local StageType = ____isaac_2Dtypescript_2Ddefinitions.StageType
|
|
4
|
+
____exports.STAGE_TYPE_SUFFIXES = {
|
|
5
|
+
[StageType.ORIGINAL] = "",
|
|
6
|
+
[StageType.WRATH_OF_THE_LAMB] = "a",
|
|
7
|
+
[StageType.AFTERBIRTH] = "b",
|
|
8
|
+
[StageType.GREED_MODE] = "",
|
|
9
|
+
[StageType.REPENTANCE] = "c",
|
|
10
|
+
[StageType.REPENTANCE_B] = "d"
|
|
11
|
+
}
|
|
12
|
+
return ____exports
|