isaacscript-common 2.3.2 → 3.0.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/cachedClasses.lua +24 -0
- package/callbacks/customRevive.lua +2 -0
- package/callbacks/itemPickup.lua +2 -0
- package/callbacks/postBombInitLate.lua +2 -0
- package/callbacks/postBoneSwing.lua +2 -0
- package/callbacks/postCollectibleInitFirst.lua +2 -0
- package/callbacks/postCursedTeleport.lua +2 -0
- package/callbacks/postCustomDoorEnter.lua +44 -0
- package/callbacks/postDoorRender.lua +2 -0
- package/callbacks/postDoorUpdate.lua +2 -0
- package/callbacks/postEffectInitLate.lua +2 -0
- package/callbacks/postEffectStateChanged.lua +2 -0
- package/callbacks/postEsauJr.lua +2 -0
- package/callbacks/postFamiliarInitLate.lua +2 -0
- package/callbacks/postFamiliarStateChanged.lua +2 -0
- package/callbacks/postFlip.lua +2 -0
- package/callbacks/postGreedModeWave.lua +2 -0
- package/callbacks/postGridEntity.lua +2 -0
- package/callbacks/postGridEntityCollision.lua +2 -0
- package/callbacks/postGridEntityRender.lua +2 -0
- package/callbacks/postHolyMantleRemoved.lua +2 -0
- package/callbacks/postKnifeInitLate.lua +2 -0
- package/callbacks/postLaserInitLate.lua +2 -0
- package/callbacks/postNPCInitLate.lua +2 -0
- package/callbacks/postNPCStateChanged.lua +2 -0
- package/callbacks/postNewRoomEarly.lua +2 -0
- package/callbacks/postPickupCollect.lua +2 -0
- package/callbacks/postPickupInitLate.lua +2 -0
- package/callbacks/postPickupStateChanged.lua +2 -0
- package/callbacks/postPitRender.lua +2 -0
- package/callbacks/postPitUpdate.lua +2 -0
- package/callbacks/postPlayerChangeHealth.lua +2 -0
- package/callbacks/postPlayerChangeType.lua +2 -0
- package/callbacks/postPlayerFatalDamage.lua +2 -0
- package/callbacks/postPlayerInitLate.lua +2 -0
- package/callbacks/postPlayerReordered.lua +2 -0
- package/callbacks/postPoopRender.lua +2 -0
- package/callbacks/postPoopUpdate.lua +2 -0
- package/callbacks/postPressurePlateRender.lua +2 -0
- package/callbacks/postPressurePlateUpdate.lua +2 -0
- package/callbacks/postProjectileInitLate.lua +2 -0
- package/callbacks/postPurchase.lua +2 -0
- package/callbacks/postRockRender.lua +2 -0
- package/callbacks/postRockUpdate.lua +2 -0
- package/callbacks/postRoomClearChanged.lua +2 -0
- package/callbacks/postSacrifice.lua +2 -0
- package/callbacks/postSlotInitUpdate.lua +2 -0
- package/callbacks/postSlotRender.lua +2 -0
- package/callbacks/postSpikesRender.lua +2 -0
- package/callbacks/postSpikesUpdate.lua +2 -0
- package/callbacks/postTNTRender.lua +2 -0
- package/callbacks/postTNTUpdate.lua +2 -0
- package/callbacks/postTearInitLate.lua +2 -0
- package/callbacks/postTearInitVeryLate.lua +2 -0
- package/callbacks/postTransformation.lua +2 -0
- package/callbacks/postTrinketBreak.lua +2 -0
- package/callbacks/preBerserkDeath.lua +2 -0
- package/callbacks/preNewLevel.lua +2 -0
- package/callbacks/reorderedCallbacks.lua +16 -0
- package/callbacks/subscriptions/postBombInitLate.lua +6 -0
- package/callbacks/subscriptions/postBoneSwing.lua +6 -0
- package/callbacks/subscriptions/postCollectibleInitFirst.lua +6 -0
- package/callbacks/subscriptions/postCursedTeleport.lua +6 -0
- package/callbacks/subscriptions/postCustomDoorEnter.lua +6 -0
- package/callbacks/subscriptions/postCustomRevive.lua +6 -0
- package/callbacks/subscriptions/postDoorRender.lua +6 -0
- package/callbacks/subscriptions/postDoorUpdate.lua +6 -0
- package/callbacks/subscriptions/postEffectInitLate.lua +6 -0
- package/callbacks/subscriptions/postEffectStateChanged.lua +6 -0
- package/callbacks/subscriptions/postEsauJr.lua +6 -0
- package/callbacks/subscriptions/postFamiliarInitLate.lua +6 -0
- package/callbacks/subscriptions/postFamiliarStateChanged.lua +6 -0
- package/callbacks/subscriptions/postFirstEsauJr.lua +6 -0
- package/callbacks/subscriptions/postFirstFlip.lua +6 -0
- package/callbacks/subscriptions/postFlip.lua +6 -0
- package/callbacks/subscriptions/postGameStartedReordered.lua +6 -0
- package/callbacks/subscriptions/postGreedModeWave.lua +6 -0
- package/callbacks/subscriptions/postGridEntityBroken.lua +6 -0
- package/callbacks/subscriptions/postGridEntityCollision.lua +6 -0
- package/callbacks/subscriptions/postGridEntityInit.lua +6 -0
- package/callbacks/subscriptions/postGridEntityRemove.lua +6 -0
- package/callbacks/subscriptions/postGridEntityRender.lua +6 -0
- package/callbacks/subscriptions/postGridEntityStateChanged.lua +6 -0
- package/callbacks/subscriptions/postGridEntityUpdate.lua +6 -0
- package/callbacks/subscriptions/postHolyMantleRemoved.lua +6 -0
- package/callbacks/subscriptions/postItemDischarged.lua +6 -0
- package/callbacks/subscriptions/postItemPickup.lua +6 -0
- package/callbacks/subscriptions/postKnifeInitLate.lua +6 -0
- package/callbacks/subscriptions/postLaserInitLate.lua +6 -0
- package/callbacks/subscriptions/postNPCInitLate.lua +6 -0
- package/callbacks/subscriptions/postNPCStateChanged.lua +6 -0
- package/callbacks/subscriptions/postNewLevelReordered.lua +6 -0
- package/callbacks/subscriptions/postNewRoomEarly.lua +6 -0
- package/callbacks/subscriptions/postNewRoomReordered.lua +6 -0
- package/callbacks/subscriptions/postPEffectUpdateReordered.lua +6 -0
- package/callbacks/subscriptions/postPickupCollect.lua +6 -0
- package/callbacks/subscriptions/postPickupInitLate.lua +6 -0
- package/callbacks/subscriptions/postPickupStateChanged.lua +6 -0
- package/callbacks/subscriptions/postPitRender.lua +6 -0
- package/callbacks/subscriptions/postPitUpdate.lua +6 -0
- package/callbacks/subscriptions/postPlayerChangeHealth.lua +6 -0
- package/callbacks/subscriptions/postPlayerChangeType.lua +6 -0
- package/callbacks/subscriptions/postPlayerFatalDamage.lua +6 -0
- package/callbacks/subscriptions/postPlayerInitLate.lua +6 -0
- package/callbacks/subscriptions/postPlayerInitReordered.lua +6 -0
- package/callbacks/subscriptions/postPlayerRenderReordered.lua +6 -0
- package/callbacks/subscriptions/postPlayerUpdateReordered.lua +6 -0
- package/callbacks/subscriptions/postPoopRender.lua +6 -0
- package/callbacks/subscriptions/postPoopUpdate.lua +6 -0
- package/callbacks/subscriptions/postPressurePlateRender.lua +6 -0
- package/callbacks/subscriptions/postPressurePlateUpdate.lua +6 -0
- package/callbacks/subscriptions/postProjectileInitLate.lua +6 -0
- package/callbacks/subscriptions/postPurchase.lua +6 -0
- package/callbacks/subscriptions/postRockRender.lua +6 -0
- package/callbacks/subscriptions/postRockUpdate.lua +6 -0
- package/callbacks/subscriptions/postRoomClearChanged.lua +6 -0
- package/callbacks/subscriptions/postSacrifice.lua +6 -0
- package/callbacks/subscriptions/postSlotAnimationChanged.lua +6 -0
- package/callbacks/subscriptions/postSlotDestroyed.lua +6 -0
- package/callbacks/subscriptions/postSlotInit.lua +6 -0
- package/callbacks/subscriptions/postSlotRender.lua +6 -0
- package/callbacks/subscriptions/postSlotUpdate.lua +6 -0
- package/callbacks/subscriptions/postSpikesRender.lua +6 -0
- package/callbacks/subscriptions/postSpikesUpdate.lua +6 -0
- package/callbacks/subscriptions/postTNTRender.lua +6 -0
- package/callbacks/subscriptions/postTNTUpdate.lua +6 -0
- package/callbacks/subscriptions/postTearInitLate.lua +6 -0
- package/callbacks/subscriptions/postTearInitVeryLate.lua +6 -0
- package/callbacks/subscriptions/postTransformation.lua +6 -0
- package/callbacks/subscriptions/postTrinketBreak.lua +6 -0
- package/callbacks/subscriptions/preBerserkDeath.lua +6 -0
- package/callbacks/subscriptions/preCustomRevive.lua +6 -0
- package/callbacks/subscriptions/preItemPickup.lua +6 -0
- package/callbacks/subscriptions/preNewLevel.lua +6 -0
- package/classes/DefaultMap.d.ts +70 -39
- package/classes/DefaultMap.lua +94 -43
- package/classes/ModUpgraded.d.ts +3 -3
- package/classes/ModUpgraded.lua +5 -0
- package/constants.lua +41 -0
- package/constantsFirstLast.lua +63 -0
- package/enums/HealthType.lua +3 -0
- package/enums/ModCallbackCustom.d.ts +1 -1
- package/enums/ModCallbackCustom.lua +6 -0
- package/enums/private/CopyableIsaacAPIClassType.lua +1 -0
- package/enums/private/SerializationBrand.lua +5 -0
- package/features/characterHealthConversion.lua +6 -0
- package/features/characterStats.lua +17 -0
- package/features/debugDisplay/exports.lua +90 -0
- package/features/deployJSONRoom.lua +56 -0
- package/features/disableInputs.lua +45 -0
- package/features/disableSound.lua +14 -0
- package/features/extraConsoleCommands/commandsDisplay.lua +90 -0
- package/features/extraConsoleCommands/init.lua +16 -0
- package/features/extraConsoleCommands/listCommands.lua +172 -0
- package/features/fadeInRemover.lua +10 -0
- package/features/fastReset.lua +10 -0
- package/features/forgottenSwitch.lua +4 -0
- package/features/getCollectibleItemPoolType.lua +5 -0
- package/features/playerInventory.lua +18 -0
- package/features/ponyDetection.lua +4 -0
- package/features/preventCollectibleRotation.lua +9 -0
- package/features/runInNFrames.lua +50 -0
- package/features/saveDataManager/constants.lua +1 -0
- package/features/saveDataManager/exports.lua +115 -0
- package/features/saveDataManager/main.lua +6 -0
- package/features/saveDataManager/maps.lua +3 -0
- package/features/saveDataManager/merge.lua +20 -0
- package/features/sirenHelpers.lua +13 -0
- package/features/taintedLazarusPlayers.lua +11 -0
- package/featuresInitialized.lua +6 -0
- package/functions/array.lua +85 -0
- package/functions/benchmark.lua +6 -0
- package/functions/boss.lua +35 -0
- package/functions/cacheFlag.lua +4 -0
- package/functions/cards.lua +60 -0
- package/functions/challenges.lua +1 -0
- package/functions/character.lua +23 -0
- package/functions/charge.lua +39 -0
- package/functions/chargeBar.lua +4 -0
- package/functions/collectibleCacheFlag.lua +15 -0
- package/functions/collectibleSet.lua +3 -0
- package/functions/collectibleTag.lua +9 -0
- package/functions/collectibles.lua +131 -0
- package/functions/color.lua +18 -0
- package/functions/debug.lua +18 -0
- package/functions/deepCopy.lua +25 -0
- package/functions/doors.lua +53 -0
- package/functions/entity.lua +88 -0
- package/functions/entitySpecific.lua +182 -0
- package/functions/entityTypes.d.ts +1 -1
- package/functions/entityTypes.lua +1 -0
- package/functions/enums.lua +62 -0
- package/functions/familiars.lua +52 -0
- package/functions/flag.lua +77 -0
- package/functions/flying.lua +10 -0
- package/functions/globals.lua +6 -0
- package/functions/gridEntity.lua +105 -0
- package/functions/gridEntitySpecific.lua +8 -0
- package/functions/input.lua +11 -0
- package/functions/isaacAPIClass.lua +12 -0
- package/functions/jsonHelpers.lua +11 -0
- package/functions/jsonRoom.lua +5 -0
- package/functions/kColor.lua +9 -0
- package/functions/language.lua +5 -0
- package/functions/log.lua +28 -0
- package/functions/map.lua +18 -0
- package/functions/math.lua +26 -0
- package/functions/npc.lua +24 -0
- package/functions/pickupVariants.d.ts +11 -11
- package/functions/pickupVariants.lua +11 -0
- package/functions/pickups.lua +67 -0
- package/functions/pills.lua +45 -0
- package/functions/player.lua +166 -0
- package/functions/playerDataStructures.lua +65 -0
- package/functions/playerHealth.lua +10 -0
- package/functions/playerIndex.lua +47 -0
- package/functions/pocketItems.lua +18 -0
- package/functions/positionVelocity.lua +46 -0
- package/functions/random.lua +32 -0
- package/functions/revive.lua +15 -0
- package/functions/rng.lua +19 -0
- package/functions/roomData.lua +68 -0
- package/functions/roomGrid.lua +21 -0
- package/functions/roomShape.lua +22 -0
- package/functions/rooms.lua +100 -0
- package/functions/run.lua +5 -0
- package/functions/seeds.lua +4 -0
- package/functions/serialization.lua +4 -0
- package/functions/set.lua +22 -0
- package/functions/spawnCollectible.lua +24 -0
- package/functions/sprite.lua +25 -0
- package/functions/stage.lua +16 -0
- package/functions/string.lua +6 -0
- package/functions/table.lua +19 -0
- package/functions/tears.lua +12 -0
- package/functions/transformations.lua +18 -0
- package/functions/trinketCacheFlag.lua +3 -0
- package/functions/trinketGive.lua +24 -0
- package/functions/trinkets.lua +52 -0
- package/functions/tstlClass.lua +9 -0
- package/functions/ui.lua +16 -0
- package/functions/utils.d.ts +1 -0
- package/functions/utils.lua +88 -0
- package/functions/vector.lua +9 -0
- package/lualib_bundle.lua +21 -34
- package/maps/cardMap.lua +1 -0
- package/maps/characterMap.lua +1 -0
- package/maps/defaultPlayerStatMap.lua +1 -0
- package/maps/gridEntityXMLMap.lua +2 -0
- package/maps/pillEffectMap.lua +1 -0
- package/maps/roomShapeToTopLeftWallGridIndexMap.lua +2 -0
- package/maps/roomTypeMap.lua +1 -0
- package/objects/LRoomShapeToRectangles.lua +2 -0
- package/objects/colors.lua +4 -0
- package/objects/roomShapeBounds.lua +2 -0
- package/objects/roomShapeLayoutSizes.lua +4 -0
- package/objects/roomShapeToBottomRightPosition.lua +2 -0
- package/objects/roomShapeToDoorSlotsToGridIndexDelta.lua +2 -0
- package/objects/roomShapeToTopLeftPosition.lua +2 -0
- package/objects/roomShapeVolumes.lua +3 -0
- package/package.json +2 -2
- package/patchErrorFunctions.lua +8 -0
- package/sets/bossSets.lua +23 -0
- package/sets/charactersWithNoRedHeartsSet.lua +2 -0
- package/sets/charactersWithNoSoulHeartsSet.lua +2 -0
- package/sets/lostStyleCharactersSet.lua +2 -0
- package/types/PickingUpItem.lua +7 -0
- package/upgradeMod.d.ts +4 -4
- package/upgradeMod.lua +18 -0
package/functions/rooms.lua
CHANGED
|
@@ -68,6 +68,13 @@ local irange = ____utils.irange
|
|
|
68
68
|
function ____exports.getRoomShapeNeighborGridIndexDeltas(self, roomShape)
|
|
69
69
|
return {__TS__Spread(ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA[roomShape]:values())}
|
|
70
70
|
end
|
|
71
|
+
--- Helper function to get the room descriptor for every room on the level. Uses the `Level.GetRooms`
|
|
72
|
+
-- method to accomplish this. Rooms without data are assumed to be non-existent and are not added to
|
|
73
|
+
-- the list.
|
|
74
|
+
--
|
|
75
|
+
-- @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
|
|
76
|
+
-- extra-dimensional rooms are automatically be generated and can be
|
|
77
|
+
-- seen when you iterate over the `RoomList`. Default is false.
|
|
71
78
|
function ____exports.getRooms(self, includeExtraDimensionalRooms)
|
|
72
79
|
if includeExtraDimensionalRooms == nil then
|
|
73
80
|
includeExtraDimensionalRooms = false
|
|
@@ -96,15 +103,21 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
|
|
|
96
103
|
end
|
|
97
104
|
return {__TS__Spread(roomsMap:values())}
|
|
98
105
|
end
|
|
106
|
+
--- We cannot use the standard code in the `inDimension` function for this purpose since it is bugged
|
|
107
|
+
-- with the Death Certificate area.
|
|
99
108
|
function ____exports.inDeathCertificateArea(self)
|
|
100
109
|
local roomStageID = getRoomStageID(nil)
|
|
101
110
|
local roomSubType = getRoomSubType(nil)
|
|
102
111
|
return roomStageID == StageID.HOME and (roomSubType == HomeRoomSubType.DEATH_CERTIFICATE_ENTRANCE or roomSubType == HomeRoomSubType.DEATH_CERTIFICATE_ITEMS)
|
|
103
112
|
end
|
|
113
|
+
--- Helper function to check if a room exists at the given room grid index.
|
|
104
114
|
function ____exports.roomExists(self, roomGridIndex)
|
|
105
115
|
local roomData = getRoomData(nil, roomGridIndex)
|
|
106
116
|
return roomData ~= nil
|
|
107
117
|
end
|
|
118
|
+
--- Helper function for quickly switching to a new room without playing a particular animation. Use
|
|
119
|
+
-- this helper function over invoking the `Game.ChangeRoom` method directly to ensure that you do
|
|
120
|
+
-- not forget to set the `LeaveDoor` property and to prevent crashing on invalid room grid indexes.
|
|
108
121
|
function ____exports.changeRoom(self, roomGridIndex)
|
|
109
122
|
local level = game:GetLevel()
|
|
110
123
|
local roomData = getRoomData(nil, roomGridIndex)
|
|
@@ -114,6 +127,7 @@ function ____exports.changeRoom(self, roomGridIndex)
|
|
|
114
127
|
level.LeaveDoor = DoorSlot.NO_DOOR_SLOT
|
|
115
128
|
game:ChangeRoom(roomGridIndex)
|
|
116
129
|
end
|
|
130
|
+
--- Helper function to get an array with every valid `Dimension` (not including `Dimension.CURRENT`).
|
|
117
131
|
function ____exports.getAllDimensions(self)
|
|
118
132
|
return erange(nil, NUM_DIMENSIONS)
|
|
119
133
|
end
|
|
@@ -124,6 +138,11 @@ function ____exports.getAllRoomGridIndexes(self)
|
|
|
124
138
|
function(____, roomDescriptor) return roomDescriptor.SafeGridIndex end
|
|
125
139
|
)
|
|
126
140
|
end
|
|
141
|
+
--- Helper function to get the current dimension. Most of the time, this will be `Dimension.MAIN`,
|
|
142
|
+
-- but it can change if e.g. the player is in the mirror world of Downpour/Dross.
|
|
143
|
+
--
|
|
144
|
+
-- Note that this function correctly handles detecting the Death Certificate dimension, which is
|
|
145
|
+
-- tricky to properly detect.
|
|
127
146
|
function ____exports.getCurrentDimension(self)
|
|
128
147
|
local level = game:GetLevel()
|
|
129
148
|
if ____exports.inDeathCertificateArea(nil) then
|
|
@@ -141,10 +160,19 @@ function ____exports.getCurrentDimension(self)
|
|
|
141
160
|
end
|
|
142
161
|
return error("Failed to get the current dimension using the starting room index of: " .. tostring(startingRoomGridIndex))
|
|
143
162
|
end
|
|
163
|
+
--- Helper function to get the number of rooms that are currently on the floor layout. This does not
|
|
164
|
+
-- include off-grid rooms, like the Devil Room.
|
|
144
165
|
function ____exports.getNumRooms(self)
|
|
145
166
|
local rooms = ____exports.getRooms(nil)
|
|
146
167
|
return #rooms
|
|
147
168
|
end
|
|
169
|
+
--- Helper function to get an array of all of the safe grid indexes for rooms that match the
|
|
170
|
+
-- specified room type.
|
|
171
|
+
--
|
|
172
|
+
-- This function only searches through rooms in the current dimension.
|
|
173
|
+
--
|
|
174
|
+
-- This function is variadic, meaning that you can specify N arguments to get the combined grid
|
|
175
|
+
-- indexes for N room types.
|
|
148
176
|
function ____exports.getRoomGridIndexesForType(self, ...)
|
|
149
177
|
local roomTypesSet = __TS__New(Set, {...})
|
|
150
178
|
local rooms = ____exports.getRooms(nil)
|
|
@@ -157,6 +185,8 @@ function ____exports.getRoomGridIndexesForType(self, ...)
|
|
|
157
185
|
function(____, roomDescriptor) return roomDescriptor.SafeGridIndex end
|
|
158
186
|
)
|
|
159
187
|
end
|
|
188
|
+
--- Helper function to get the item pool type for the current room. For example, this returns
|
|
189
|
+
-- `ItemPoolType.ItemPoolType.POOL_ANGEL` if you are in an Angel Room.
|
|
160
190
|
function ____exports.getRoomItemPoolType(self)
|
|
161
191
|
local itemPool = game:GetItemPool()
|
|
162
192
|
local room = game:GetRoom()
|
|
@@ -164,6 +194,9 @@ function ____exports.getRoomItemPoolType(self)
|
|
|
164
194
|
local roomSeed = room:GetSpawnSeed()
|
|
165
195
|
return itemPool:GetPoolForRoom(roomType, roomSeed)
|
|
166
196
|
end
|
|
197
|
+
--- Helper function to get the grid indexes of all the rooms connected to the given room index.
|
|
198
|
+
--
|
|
199
|
+
-- @param roomGridIndex Optional. Default is the current room index.
|
|
167
200
|
function ____exports.getRoomNeighbors(self, roomGridIndex)
|
|
168
201
|
local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
|
|
169
202
|
if roomDescriptor.SafeGridIndex < 0 or roomDescriptor.SafeGridIndex > MAX_LEVEL_GRID_INDEX then
|
|
@@ -184,10 +217,18 @@ function ____exports.getRoomNeighbors(self, roomGridIndex)
|
|
|
184
217
|
function(____, gridIndex) return ____exports.roomExists(nil, gridIndex) end
|
|
185
218
|
)
|
|
186
219
|
end
|
|
220
|
+
--- Helper function to get the proper name of a room type.
|
|
221
|
+
--
|
|
222
|
+
-- For example, `RoomType.TREASURE` will return "Treasure Room".
|
|
187
223
|
function ____exports.getRoomTypeName(self, roomType)
|
|
188
224
|
local roomTypeName = ROOM_TYPE_NAMES[roomType]
|
|
189
225
|
return roomTypeName == nil and DEFAULT_ROOM_TYPE_NAME or roomTypeName
|
|
190
226
|
end
|
|
227
|
+
--- Helper function to get the room descriptor for every room on the level in a specific dimension.
|
|
228
|
+
-- Uses the `Level.GetRooms` method to accomplish this. Rooms without data are assumed to be
|
|
229
|
+
-- non-existent and are not added to the list.
|
|
230
|
+
--
|
|
231
|
+
-- @returns A map of room ListIndex to RoomDescriptor.
|
|
191
232
|
function ____exports.getRoomsOfDimension(self, dimension)
|
|
192
233
|
local level = game:GetLevel()
|
|
193
234
|
local roomsMap = __TS__New(Map)
|
|
@@ -199,6 +240,8 @@ function ____exports.getRoomsOfDimension(self, dimension)
|
|
|
199
240
|
end
|
|
200
241
|
return {__TS__Spread(roomsMap:values())}
|
|
201
242
|
end
|
|
243
|
+
--- Helper function to determine if the current room shape is equal to `RoomShape.1x2` or
|
|
244
|
+
-- `RoomShape.2x1`.
|
|
202
245
|
function ____exports.in2x1Room(self)
|
|
203
246
|
local room = game:GetRoom()
|
|
204
247
|
local roomShape = room:GetRoomShape()
|
|
@@ -216,6 +259,8 @@ function ____exports.inBeastRoom(self)
|
|
|
216
259
|
local roomSubType = getRoomSubType(nil)
|
|
217
260
|
return roomType == RoomType.DUNGEON and roomSubType == DungeonSubType.BEAST_ROOM
|
|
218
261
|
end
|
|
262
|
+
--- Helper function to check if the current room is a boss room for a particular boss. This will only
|
|
263
|
+
-- work for bosses that have dedicated boss rooms in the "00.special rooms.stb" file.
|
|
219
264
|
function ____exports.inBossRoomOf(self, bossID)
|
|
220
265
|
local room = game:GetRoom()
|
|
221
266
|
local roomType = room:GetType()
|
|
@@ -223,12 +268,18 @@ function ____exports.inBossRoomOf(self, bossID)
|
|
|
223
268
|
local roomSubType = getRoomSubType(nil)
|
|
224
269
|
return roomType == RoomType.BOSS and roomStageID == StageID.SPECIAL_ROOMS and roomSubType == bossID
|
|
225
270
|
end
|
|
271
|
+
--- Helper function for determining whether the current room is a crawlspace. Use this function over
|
|
272
|
+
-- comparing to `RoomType.DUNGEON` or `GridRoom.DUNGEON_IDX` since there is a special case of the
|
|
273
|
+
-- player being in a boss fight that take place in a dungeon.
|
|
226
274
|
function ____exports.inCrawlspace(self)
|
|
227
275
|
local room = game:GetRoom()
|
|
228
276
|
local roomType = room:GetType()
|
|
229
277
|
local roomSubType = getRoomSubType(nil)
|
|
230
278
|
return roomType == RoomType.DUNGEON and roomSubType == DungeonSubType.NORMAL
|
|
231
279
|
end
|
|
280
|
+
--- Helper function to detect if the current room is a Treasure Room created when entering with a
|
|
281
|
+
-- Devil's Crown trinket. Under the hood, this checks for the `RoomDescriptorFlag.DEVIL_TREASURE`
|
|
282
|
+
-- flag.
|
|
232
283
|
function ____exports.inDevilsCrownTreasureRoom(self)
|
|
233
284
|
local roomDescriptor = getCurrentRoomDescriptorReadOnly(nil)
|
|
234
285
|
return hasFlag(nil, roomDescriptor.Flags, RoomDescriptorFlag.DEVIL_TREASURE)
|
|
@@ -246,6 +297,7 @@ function ____exports.inGenesisRoom(self)
|
|
|
246
297
|
local roomGridIndex = getRoomGridIndex(nil)
|
|
247
298
|
return roomGridIndex == GridRoom.GENESIS
|
|
248
299
|
end
|
|
300
|
+
--- Helper function to determine if the current room shape is one of the four L room shapes.
|
|
249
301
|
function ____exports.inLRoom(self)
|
|
250
302
|
local room = game:GetRoom()
|
|
251
303
|
local roomShape = room:GetRoomShape()
|
|
@@ -255,11 +307,15 @@ function ____exports.inMegaSatanRoom(self)
|
|
|
255
307
|
local roomGridIndex = getRoomGridIndex(nil)
|
|
256
308
|
return roomGridIndex == GridRoom.MEGA_SATAN
|
|
257
309
|
end
|
|
310
|
+
--- Helper function to determine if the current room is part of the Repentance "escape sequence" in
|
|
311
|
+
-- the Mines/Ashpit.
|
|
258
312
|
function ____exports.inMineShaft(self)
|
|
259
313
|
local roomStageID = getRoomStageID(nil)
|
|
260
314
|
local roomSubType = getRoomSubType(nil)
|
|
261
315
|
return (roomStageID == StageID.MINES or roomStageID == StageID.ASHPIT) and MINE_SHAFT_ROOM_SUB_TYPE_SET:has(roomSubType)
|
|
262
316
|
end
|
|
317
|
+
--- Helper function to check if the current room is a miniboss room for a particular miniboss. This
|
|
318
|
+
-- will only work for mini-bosses that have dedicated boss rooms in the "00.special rooms.stb" file.
|
|
263
319
|
function ____exports.inMinibossRoomOf(self, minibossID)
|
|
264
320
|
local room = game:GetRoom()
|
|
265
321
|
local roomType = room:GetType()
|
|
@@ -267,16 +323,31 @@ function ____exports.inMinibossRoomOf(self, minibossID)
|
|
|
267
323
|
local roomSubType = getRoomSubType(nil)
|
|
268
324
|
return roomType == RoomType.MINI_BOSS and roomStageID == StageID.SPECIAL_ROOMS and roomSubType == minibossID
|
|
269
325
|
end
|
|
326
|
+
--- Helper function for checking if the room is a secret shop (from the Member Card collectible).
|
|
327
|
+
--
|
|
328
|
+
-- Secret shops are simply copies of normal shops, but with the backdrop of a secret room. In other
|
|
329
|
+
-- words, they will have the same room type, room variant, and room sub-type of a normal shop. Thus,
|
|
330
|
+
-- the only way to detect them is by using the grid index.
|
|
270
331
|
function ____exports.inSecretShop(self)
|
|
271
332
|
local roomGridIndex = getRoomGridIndex(nil)
|
|
272
333
|
return roomGridIndex == GridRoom.SECRET_SHOP
|
|
273
334
|
end
|
|
335
|
+
--- Helper function to determine whether or not the current room is the starting room of a floor. It
|
|
336
|
+
-- only returns true for the starting room of the primary dimension (meaning that being in the
|
|
337
|
+
-- starting room of the mirror world does not count).
|
|
274
338
|
function ____exports.inStartingRoom(self)
|
|
275
339
|
local level = game:GetLevel()
|
|
276
340
|
local startingRoomGridIndex = level:GetStartingRoomIndex()
|
|
277
341
|
local roomGridIndex = getRoomGridIndex(nil)
|
|
278
342
|
return roomGridIndex == startingRoomGridIndex and ____exports.inDimension(nil, Dimension.MAIN)
|
|
279
343
|
end
|
|
344
|
+
--- Helper function to loop through every room on the floor and see if it has been cleared.
|
|
345
|
+
--
|
|
346
|
+
-- This function will only check rooms in the current dimension.
|
|
347
|
+
--
|
|
348
|
+
-- @param onlyCheckRoomTypes Optional. A whitelist of room types. If specified, room types not in
|
|
349
|
+
-- the array will be ignored. If not specified, then all rooms will be
|
|
350
|
+
-- checked. Undefined by default.
|
|
280
351
|
function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes)
|
|
281
352
|
local ____temp_0
|
|
282
353
|
if onlyCheckRoomTypes == nil then
|
|
@@ -315,21 +386,36 @@ function ____exports.isDoorSlotValidAtGridIndexForRedRoom(self, doorSlot, roomGr
|
|
|
315
386
|
local redRoomGridIndex = roomGridIndex + delta
|
|
316
387
|
return not ____exports.roomExists(nil, redRoomGridIndex) and redRoomGridIndex >= 0 and redRoomGridIndex <= MAX_LEVEL_GRID_INDEX
|
|
317
388
|
end
|
|
389
|
+
--- Helper function to detect if the provided room was created by the Red Key item. Under the hood,
|
|
390
|
+
-- this checks for the `RoomDescriptorFlag.FLAG_RED_ROOM` flag.
|
|
391
|
+
--
|
|
392
|
+
-- @param roomGridIndex Optional. Default is the current room index.
|
|
318
393
|
function ____exports.isRedKeyRoom(self, roomGridIndex)
|
|
319
394
|
local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
|
|
320
395
|
return hasFlag(nil, roomDescriptor.Flags, RoomDescriptorFlag.RED_ROOM)
|
|
321
396
|
end
|
|
397
|
+
--- Helper function to determine if the provided room is part of the floor layout. For example, Devil
|
|
398
|
+
-- Rooms and the Mega Satan room are not considered to be inside the map.
|
|
399
|
+
--
|
|
400
|
+
-- @param roomGridIndex Optional. Default is the current room index.
|
|
322
401
|
function ____exports.isRoomInsideMap(self, roomGridIndex)
|
|
323
402
|
if roomGridIndex == nil then
|
|
324
403
|
roomGridIndex = getRoomGridIndex(nil)
|
|
325
404
|
end
|
|
326
405
|
return roomGridIndex >= 0
|
|
327
406
|
end
|
|
407
|
+
--- Helper function to get the coordinates of a given grid index. The floor is represented by a 13x13
|
|
408
|
+
-- grid. For example, since the starting room is in the center, the starting room grid index of 84
|
|
409
|
+
-- be equal to coordinates of (?, ?).
|
|
328
410
|
function ____exports.roomGridIndexToXY(self, roomGridIndex)
|
|
329
411
|
local x = roomGridIndex % LEVEL_GRID_ROW_WIDTH
|
|
330
412
|
local y = math.floor(roomGridIndex / LEVEL_GRID_ROW_WIDTH)
|
|
331
413
|
return {x, y}
|
|
332
414
|
end
|
|
415
|
+
--- If the `Room.Update` method is called in a PostNewRoom callback, then some entities will slide
|
|
416
|
+
-- around (such as the player). Since those entity velocities are already at zero, setting them to
|
|
417
|
+
-- zero will have no effect. Thus, a generic solution is to record all of the entity
|
|
418
|
+
-- positions/velocities before updating the room, and then restore those positions/velocities.
|
|
333
419
|
function ____exports.roomUpdateSafe(self)
|
|
334
420
|
local room = game:GetRoom()
|
|
335
421
|
local entities = getEntities(nil)
|
|
@@ -339,6 +425,9 @@ function ____exports.roomUpdateSafe(self)
|
|
|
339
425
|
setEntityPositions(nil, entityPositions, entities)
|
|
340
426
|
setEntityVelocities(nil, entityVelocities, entities)
|
|
341
427
|
end
|
|
428
|
+
--- Helper function to convert an uncleared room to a cleared room in the PostNewRoom callback. This
|
|
429
|
+
-- is useful because if enemies are removed in this callback, a room drop will be awarded and the
|
|
430
|
+
-- doors will start closed and then open.
|
|
342
431
|
function ____exports.setRoomCleared(self)
|
|
343
432
|
local room = game:GetRoom()
|
|
344
433
|
local roomClear = room:IsClear()
|
|
@@ -359,11 +448,22 @@ function ____exports.setRoomCleared(self)
|
|
|
359
448
|
sfxManager:Stop(SoundEffect.DOOR_HEAVY_OPEN)
|
|
360
449
|
game:ShakeScreen(0)
|
|
361
450
|
end
|
|
451
|
+
--- Helper function to emulate what happens when you bomb an Angel Statue or push a Reward Plate that
|
|
452
|
+
-- spawns an NPC.
|
|
362
453
|
function ____exports.setRoomUncleared(self)
|
|
363
454
|
local room = game:GetRoom()
|
|
364
455
|
room:SetClear(false)
|
|
365
456
|
closeAllDoors(nil)
|
|
366
457
|
end
|
|
458
|
+
--- Helper function to change the current room. It can be used for both teleportation and "normal"
|
|
459
|
+
-- room transitions, depending on what is passed for the `direction` and `roomTransitionAnim`
|
|
460
|
+
-- arguments. Use this function instead of invoking the `Game.StartRoomTransition` method directly
|
|
461
|
+
-- so that you do not forget to set `Level.LeaveDoor` property and to prevent crashing on invalid
|
|
462
|
+
-- room grid indexes.
|
|
463
|
+
--
|
|
464
|
+
-- @param roomGridIndex The room grid index of the destination room.
|
|
465
|
+
-- @param direction Optional. Default is `Direction.NO_DIRECTION`.
|
|
466
|
+
-- @param roomTransitionAnim Optional. Default is `RoomTransitionAnim.TELEPORT`.
|
|
367
467
|
function ____exports.teleport(self, roomGridIndex, direction, roomTransitionAnim)
|
|
368
468
|
if direction == nil then
|
|
369
469
|
direction = Direction.NO_DIRECTION
|
package/functions/run.lua
CHANGED
|
@@ -7,12 +7,17 @@ local ____constantsFirstLast = require("constantsFirstLast")
|
|
|
7
7
|
local FIRST_CHARACTER = ____constantsFirstLast.FIRST_CHARACTER
|
|
8
8
|
local ____log = require("functions.log")
|
|
9
9
|
local log = ____log.log
|
|
10
|
+
--- Whether or not the player is playing on a set seed (i.e. that they entered in a specific seed by
|
|
11
|
+
-- pressing tab on the character selection screen). When the player resets the game on a set seed,
|
|
12
|
+
-- the game will not switch to a different seed.
|
|
10
13
|
function ____exports.onSetSeed(self)
|
|
11
14
|
local seeds = game:GetSeeds()
|
|
12
15
|
local customRun = seeds:IsCustomRun()
|
|
13
16
|
local challenge = Isaac.GetChallenge()
|
|
14
17
|
return challenge == Challenge.NULL and customRun
|
|
15
18
|
end
|
|
19
|
+
--- Helper function to restart the game using the console command of "restart". You can optionally
|
|
20
|
+
-- specify a `PlayerType` to restart the game as that character.
|
|
16
21
|
function ____exports.restart(self, character)
|
|
17
22
|
if character == nil then
|
|
18
23
|
log("Restarting.")
|
package/functions/seeds.lua
CHANGED
|
@@ -3,10 +3,14 @@ local ____cachedClasses = require("cachedClasses")
|
|
|
3
3
|
local game = ____cachedClasses.game
|
|
4
4
|
local ____rng = require("functions.rng")
|
|
5
5
|
local newRNG = ____rng.newRNG
|
|
6
|
+
--- Alias for the `Seeds.GetStartSeedString` method.
|
|
6
7
|
function ____exports.getStartSeedString(self)
|
|
7
8
|
local seeds = game:GetSeeds()
|
|
8
9
|
return seeds:GetStartSeedString()
|
|
9
10
|
end
|
|
11
|
+
--- Helper function to get the next seed value.
|
|
12
|
+
--
|
|
13
|
+
-- This function is useful when you are working with seed values directly over RNG objects.
|
|
10
14
|
function ____exports.nextSeed(self, seed)
|
|
11
15
|
local rng = newRNG(nil, seed)
|
|
12
16
|
rng:Next()
|
|
@@ -40,6 +40,10 @@ function ____exports.copyIsaacAPIClass(self, isaacAPIClass, serializationType)
|
|
|
40
40
|
end
|
|
41
41
|
return copyFunction(nil, isaacAPIClass, serializationType)
|
|
42
42
|
end
|
|
43
|
+
--- Deserialization is a special case, so we make a dedicated function for this.
|
|
44
|
+
--
|
|
45
|
+
-- There is no need for a corresponding "serializeIsaacAPIClass" function because the
|
|
46
|
+
-- "copyIsaacAPIClass" function can handles all serialization types.
|
|
43
47
|
function ____exports.deserializeIsaacAPIClass(self, serializedIsaacAPIClass)
|
|
44
48
|
local objectType = type(serializedIsaacAPIClass)
|
|
45
49
|
if objectType ~= "table" then
|
package/functions/set.lua
CHANGED
|
@@ -9,12 +9,20 @@ local ____array = require("functions.array")
|
|
|
9
9
|
local getRandomArrayElement = ____array.getRandomArrayElement
|
|
10
10
|
local ____rng = require("functions.rng")
|
|
11
11
|
local getRandomSeed = ____rng.getRandomSeed
|
|
12
|
+
--- Helper function to get a sorted array based on the contents of a set.
|
|
13
|
+
--
|
|
14
|
+
-- Normally, set values are returned in a random order, so use this function when the ordering of
|
|
15
|
+
-- the contents is important.
|
|
12
16
|
function ____exports.getSortedSetValues(self, set)
|
|
13
17
|
local values = set:values()
|
|
14
18
|
local array = {__TS__Spread(values)}
|
|
15
19
|
__TS__ArraySort(array)
|
|
16
20
|
return array
|
|
17
21
|
end
|
|
22
|
+
--- Helper function to add all of the values in one set to another set. The first set passed will be
|
|
23
|
+
-- modified in place.
|
|
24
|
+
--
|
|
25
|
+
-- This function is variadic, meaning that you can specify N sets to add to the first set.
|
|
18
26
|
function ____exports.addSetsToSet(self, mainSet, ...)
|
|
19
27
|
local setsToAdd = {...}
|
|
20
28
|
for ____, set in ipairs(setsToAdd) do
|
|
@@ -23,6 +31,9 @@ function ____exports.addSetsToSet(self, mainSet, ...)
|
|
|
23
31
|
end
|
|
24
32
|
end
|
|
25
33
|
end
|
|
34
|
+
--- Helper function to create a new set that is the composition of two or more sets.
|
|
35
|
+
--
|
|
36
|
+
-- This function is variadic, meaning that you can specify N sets.
|
|
26
37
|
function ____exports.combineSets(self, ...)
|
|
27
38
|
local sets = {...}
|
|
28
39
|
local newSet = __TS__New(Set)
|
|
@@ -33,6 +44,7 @@ function ____exports.combineSets(self, ...)
|
|
|
33
44
|
end
|
|
34
45
|
return newSet
|
|
35
46
|
end
|
|
47
|
+
--- Helper function to copy a set. (You can also use a Set constructor to accomplish this task.)
|
|
36
48
|
function ____exports.copySet(self, oldSet)
|
|
37
49
|
local newSet = __TS__New(Set)
|
|
38
50
|
for ____, value in __TS__Iterator(oldSet:values()) do
|
|
@@ -40,6 +52,10 @@ function ____exports.copySet(self, oldSet)
|
|
|
40
52
|
end
|
|
41
53
|
return newSet
|
|
42
54
|
end
|
|
55
|
+
--- Helper function to delete all of the values in one set from another set. The first set passed
|
|
56
|
+
-- will be modified in place.
|
|
57
|
+
--
|
|
58
|
+
-- This function is variadic, meaning that you can specify N sets to remove from the first set.
|
|
43
59
|
function ____exports.deleteSetsFromSet(self, mainSet, ...)
|
|
44
60
|
local setsToRemove = {...}
|
|
45
61
|
for ____, set in ipairs(setsToRemove) do
|
|
@@ -48,6 +64,12 @@ function ____exports.deleteSetsFromSet(self, mainSet, ...)
|
|
|
48
64
|
end
|
|
49
65
|
end
|
|
50
66
|
end
|
|
67
|
+
--- Helper function to get a random element from the provided set.
|
|
68
|
+
--
|
|
69
|
+
-- @param set The set to get an element from.
|
|
70
|
+
-- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
71
|
+
-- `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
72
|
+
-- @param exceptions Optional. An array of elements to skip over if selected.
|
|
51
73
|
function ____exports.getRandomSetElement(self, set, seedOrRNG, exceptions)
|
|
52
74
|
if seedOrRNG == nil then
|
|
53
75
|
seedOrRNG = getRandomSeed(nil)
|
|
@@ -20,6 +20,20 @@ local anyPlayerIs = ____player.anyPlayerIs
|
|
|
20
20
|
local ____rng = require("functions.rng")
|
|
21
21
|
local getRandomSeed = ____rng.getRandomSeed
|
|
22
22
|
local isRNG = ____rng.isRNG
|
|
23
|
+
--- Helper function to spawn a collectible. Use this instead of the `Game.Spawn` method because it
|
|
24
|
+
-- handles the cases of Tainted Keeper collectibles costing coins and preventing quest items from
|
|
25
|
+
-- being rotated by Tainted Isaac's rotation mechanic. (Rotation prevention will only occur in
|
|
26
|
+
-- upgraded mods.)
|
|
27
|
+
--
|
|
28
|
+
-- @param collectibleType The collectible type to spawn.
|
|
29
|
+
-- @param position The position to spawn the collectible at.
|
|
30
|
+
-- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
31
|
+
-- `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
32
|
+
-- @param options Optional. Set to true to make the collectible a "There's Options" style
|
|
33
|
+
-- collectible. Default is false.
|
|
34
|
+
-- @param forceFreeItem Optional. Set to true to disable the logic that gives the item a price for
|
|
35
|
+
-- Tainted Keeper. Default is false.
|
|
36
|
+
-- @param spawner Optional.
|
|
23
37
|
function ____exports.spawnCollectible(self, collectibleType, position, seedOrRNG, options, forceFreeItem, spawner)
|
|
24
38
|
if seedOrRNG == nil then
|
|
25
39
|
seedOrRNG = getRandomSeed(nil)
|
|
@@ -52,6 +66,16 @@ function ____exports.spawnCollectible(self, collectibleType, position, seedOrRNG
|
|
|
52
66
|
end
|
|
53
67
|
return collectible
|
|
54
68
|
end
|
|
69
|
+
--- Helper function to spawn an empty collectible. Doing this is tricky since spawning a collectible
|
|
70
|
+
-- with `CollectibleType.NULL` will result in spawning a collectible with a random type from the
|
|
71
|
+
-- current room's item pool.
|
|
72
|
+
--
|
|
73
|
+
-- Instead, this function arbitrarily spawns a collectible with `CollectibleType.SAD_ONION`, and
|
|
74
|
+
-- then converts it to an empty pedestal afterward.
|
|
75
|
+
--
|
|
76
|
+
-- @param position The position to spawn the empty collectible at.
|
|
77
|
+
-- @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
78
|
+
-- `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
55
79
|
function ____exports.spawnEmptyCollectible(self, position, seedOrRNG)
|
|
56
80
|
if seedOrRNG == nil then
|
|
57
81
|
seedOrRNG = getRandomSeed(nil)
|
package/functions/sprite.lua
CHANGED
|
@@ -6,11 +6,22 @@ local ____kColor = require("functions.kColor")
|
|
|
6
6
|
local kColorEquals = ____kColor.kColorEquals
|
|
7
7
|
local ____utils = require("functions.utils")
|
|
8
8
|
local erange = ____utils.erange
|
|
9
|
+
--- Helper function to check if two texels on a sprite are equivalent to each other.
|
|
9
10
|
function ____exports.texelEquals(self, sprite1, sprite2, position, layerID)
|
|
10
11
|
local kColor1 = sprite1:GetTexel(position, VectorZero, 1, layerID)
|
|
11
12
|
local kColor2 = sprite2:GetTexel(position, VectorZero, 1, layerID)
|
|
12
13
|
return kColorEquals(nil, kColor1, kColor2)
|
|
13
14
|
end
|
|
15
|
+
--- Helper function to clear a specific layer from a sprite.
|
|
16
|
+
--
|
|
17
|
+
-- This function is variadic, so pass as many layer IDs as you want to clear. If no specific layers
|
|
18
|
+
-- are passed, it will clear every layer.
|
|
19
|
+
--
|
|
20
|
+
-- Since there is no official API method to "clear" a sprite, we can work around it by setting the
|
|
21
|
+
-- spritesheet to a non-existent or completely transparent file. If the path to the spritesheet does
|
|
22
|
+
-- not exist, then this function might cause spurious errors to appear in the "log.txt file". To
|
|
23
|
+
-- silence these errors, create a transparent 1 pixel PNG file in your mod's resources folder at the
|
|
24
|
+
-- path corresponding to the "EMPTY_PNG_PATH" constant.
|
|
14
25
|
function ____exports.clearSprite(self, sprite, ...)
|
|
15
26
|
local layerIDs = {...}
|
|
16
27
|
if #layerIDs == 0 then
|
|
@@ -22,6 +33,15 @@ function ____exports.clearSprite(self, sprite, ...)
|
|
|
22
33
|
end
|
|
23
34
|
sprite:LoadGraphics()
|
|
24
35
|
end
|
|
36
|
+
--- Helper function that returns the number of the final frame in a particular animation for a
|
|
37
|
+
-- sprite. By default, it will use the currently playing animation, but you can also specify a
|
|
38
|
+
-- specific animation to check.
|
|
39
|
+
--
|
|
40
|
+
-- Note that this function is bugged with the Stop Watch or the Broken Watch, since using the
|
|
41
|
+
-- `Sprite.SetFrame` method will reset the internal accumulator used to slow down the playback speed
|
|
42
|
+
-- of the animation. (The `PlaybackSpeed` property of the sprite is not used.) Thus, it is only safe
|
|
43
|
+
-- to use this function on animations that are not slowed down by Stop Watch or Broken Watch, such
|
|
44
|
+
-- as player animations.
|
|
25
45
|
function ____exports.getLastFrameOfAnimation(self, sprite, animation)
|
|
26
46
|
local currentAnimation = sprite:GetAnimation()
|
|
27
47
|
local currentFrame = sprite:GetFrame()
|
|
@@ -36,6 +56,11 @@ function ____exports.getLastFrameOfAnimation(self, sprite, animation)
|
|
|
36
56
|
sprite:SetFrame(currentFrame)
|
|
37
57
|
return finalFrame
|
|
38
58
|
end
|
|
59
|
+
--- Helper function to check if two sprite layers have the same sprite sheet by using the
|
|
60
|
+
-- `Sprite.GetTexel` method.
|
|
61
|
+
--
|
|
62
|
+
-- Since checking every single texel in the entire sprite is very expensive, this function requires
|
|
63
|
+
-- that you provide a range of specific texels to check.
|
|
39
64
|
function ____exports.spriteEquals(self, sprite1, sprite2, layerID, xStart, xFinish, xIncrement, yStart, yFinish, yIncrement)
|
|
40
65
|
do
|
|
41
66
|
local x = xStart
|
package/functions/stage.lua
CHANGED
|
@@ -14,9 +14,16 @@ function ____exports.onRepentanceStage(self)
|
|
|
14
14
|
local stageType = level:GetStageType()
|
|
15
15
|
return ____exports.isRepentanceStage(nil, stageType)
|
|
16
16
|
end
|
|
17
|
+
--- Helper function to convert a numerical `StageType` into the letter suffix supplied to the "stage"
|
|
18
|
+
-- console command. For example, `StageType.REPENTANCE` is the stage type for Downpour, and the
|
|
19
|
+
-- console command to go to Downpour is "stage 1c", so this function converts `StageType.REPENTANCE`
|
|
20
|
+
-- to "c".
|
|
17
21
|
function ____exports.stageTypeToLetter(self, stageType)
|
|
18
22
|
return STAGE_TYPE_TO_LETTER[stageType]
|
|
19
23
|
end
|
|
24
|
+
--- Helper function to account for Repentance floors being offset by 1. For example, Downpour 2 is
|
|
25
|
+
-- the third level of the run, but the game considers it to have a stage of 2. This function will
|
|
26
|
+
-- consider Downpour 2 to have a stage of 3.
|
|
20
27
|
function ____exports.getEffectiveStage(self)
|
|
21
28
|
local level = game:GetLevel()
|
|
22
29
|
local stage = level:GetStage()
|
|
@@ -25,14 +32,17 @@ function ____exports.getEffectiveStage(self)
|
|
|
25
32
|
end
|
|
26
33
|
return stage
|
|
27
34
|
end
|
|
35
|
+
--- Alias for the `Level.GetStage` method.
|
|
28
36
|
function ____exports.getStage(self)
|
|
29
37
|
local level = game:GetLevel()
|
|
30
38
|
return level:GetStage()
|
|
31
39
|
end
|
|
40
|
+
--- Alias for the `Level.GetStageType` method.
|
|
32
41
|
function ____exports.getStageType(self)
|
|
33
42
|
local level = game:GetLevel()
|
|
34
43
|
return level:GetStageType()
|
|
35
44
|
end
|
|
45
|
+
--- Helper function to directly warp to a specific stage using the "stage" console command.
|
|
36
46
|
function ____exports.goToStage(self, stage, stageType)
|
|
37
47
|
local stageTypeLetterSuffix = ____exports.stageTypeToLetter(nil, stageType)
|
|
38
48
|
local command = ("stage " .. tostring(stage)) .. stageTypeLetterSuffix
|
|
@@ -56,6 +66,12 @@ function ____exports.onDarkRoom(self)
|
|
|
56
66
|
local stageType = level:GetStageType()
|
|
57
67
|
return stage == LevelStage.DARK_ROOM_CHEST and stageType == StageType.ORIGINAL
|
|
58
68
|
end
|
|
69
|
+
--- Returns whether or not the player is on the "final floor" of the particular run. The final floor
|
|
70
|
+
-- is defined as one that prevents the player from entering the I AM ERROR room on.
|
|
71
|
+
--
|
|
72
|
+
-- For example, when using Undefined on The Chest, it has a 50% chance of teleporting the player to
|
|
73
|
+
-- the Secret Room and a 50% chance of teleporting the player to the Super Secret Room, because the
|
|
74
|
+
-- I AM ERROR room is never entered into the list of possibilities.
|
|
59
75
|
function ____exports.onFinalFloor(self)
|
|
60
76
|
local level = game:GetLevel()
|
|
61
77
|
local stage = level:GetStage()
|
package/functions/string.lua
CHANGED
|
@@ -13,6 +13,10 @@ end
|
|
|
13
13
|
function ____exports.removeAllCharacters(self, ____string, character)
|
|
14
14
|
return __TS__StringReplaceAll(____string, character, "")
|
|
15
15
|
end
|
|
16
|
+
--- Helper function to remove one or more substrings from a string, if they exist. Returns the
|
|
17
|
+
-- modified string.
|
|
18
|
+
--
|
|
19
|
+
-- This function is variadic, meaning that you can pass as many substrings as you want to remove.
|
|
16
20
|
function ____exports.removeSubstring(self, ____string, ...)
|
|
17
21
|
local substrings = {...}
|
|
18
22
|
for ____, substring in ipairs(substrings) do
|
|
@@ -20,12 +24,14 @@ function ____exports.removeSubstring(self, ____string, ...)
|
|
|
20
24
|
end
|
|
21
25
|
return ____string
|
|
22
26
|
end
|
|
27
|
+
--- Helper function to trim a prefix from a string, if it exists. Returns the trimmed string.
|
|
23
28
|
function ____exports.trimPrefix(self, ____string, prefix)
|
|
24
29
|
if not __TS__StringStartsWith(____string, prefix) then
|
|
25
30
|
return ____string
|
|
26
31
|
end
|
|
27
32
|
return __TS__StringSlice(____string, #prefix)
|
|
28
33
|
end
|
|
34
|
+
--- Helper function to trim a suffix from a string, if it exists. Returns the trimmed string.
|
|
29
35
|
function ____exports.trimSuffix(self, ____string, prefix)
|
|
30
36
|
if not __TS__StringEndsWith(____string, prefix) then
|
|
31
37
|
return ____string
|
package/functions/table.lua
CHANGED
|
@@ -2,11 +2,14 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
3
3
|
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
|
|
4
4
|
local ____exports = {}
|
|
5
|
+
--- In a Map, you can use the `clear` method to delete every element. However, in a LuaTable, the
|
|
6
|
+
-- `clear` method does not exist. Use this helper function as a drop-in replacement for this.
|
|
5
7
|
function ____exports.clearTable(self, ____table)
|
|
6
8
|
for key in pairs(____table) do
|
|
7
9
|
____table[key] = nil
|
|
8
10
|
end
|
|
9
11
|
end
|
|
12
|
+
--- Helper function to copy specific values from a object to a table.
|
|
10
13
|
function ____exports.copyValuesToTable(self, object, keys, ____table)
|
|
11
14
|
local otherTable = object
|
|
12
15
|
for ____, key in ipairs(keys) do
|
|
@@ -14,6 +17,10 @@ function ____exports.copyValuesToTable(self, object, keys, ____table)
|
|
|
14
17
|
____table[key] = value
|
|
15
18
|
end
|
|
16
19
|
end
|
|
20
|
+
--- Helper function to safely get boolean values from a Lua table. Will throw an error if the
|
|
21
|
+
-- specific value does not exist on the table.
|
|
22
|
+
--
|
|
23
|
+
-- This function is variadic, meaning that you can specify N arguments to get N values.
|
|
17
24
|
function ____exports.getBooleansFromTable(self, ____table, objectName, ...)
|
|
18
25
|
local keys = {...}
|
|
19
26
|
local booleans = {}
|
|
@@ -30,6 +37,10 @@ function ____exports.getBooleansFromTable(self, ____table, objectName, ...)
|
|
|
30
37
|
end
|
|
31
38
|
return booleans
|
|
32
39
|
end
|
|
40
|
+
--- Helper function to safely get number values from a Lua table. Will throw an error if the specific
|
|
41
|
+
-- value does not exist on the table or if it cannot be converted to a number.
|
|
42
|
+
--
|
|
43
|
+
-- This function is variadic, meaning that you can specify N arguments to get N values.
|
|
33
44
|
function ____exports.getNumbersFromTable(self, ____table, objectName, ...)
|
|
34
45
|
local keys = {...}
|
|
35
46
|
local numbers = {}
|
|
@@ -52,6 +63,10 @@ function ____exports.getNumbersFromTable(self, ____table, objectName, ...)
|
|
|
52
63
|
end
|
|
53
64
|
return numbers
|
|
54
65
|
end
|
|
66
|
+
--- Helper function to safely get string values from a Lua table. Will throw an error if the specific
|
|
67
|
+
-- value does not exist on the table.
|
|
68
|
+
--
|
|
69
|
+
-- This function is variadic, meaning that you can specify N arguments to get N values.
|
|
55
70
|
function ____exports.getStringsFromTable(self, ____table, objectName, ...)
|
|
56
71
|
local keys = {...}
|
|
57
72
|
local strings = {}
|
|
@@ -69,6 +84,10 @@ function ____exports.getStringsFromTable(self, ____table, objectName, ...)
|
|
|
69
84
|
end
|
|
70
85
|
return strings
|
|
71
86
|
end
|
|
87
|
+
--- Helper function to check if a Lua table has all of the provided keys.
|
|
88
|
+
--
|
|
89
|
+
-- This function is variadic, meaning that you can specify as many arguments as you want to check
|
|
90
|
+
-- for.
|
|
72
91
|
function ____exports.tableHasKeys(self, ____table, ...)
|
|
73
92
|
local keys = {...}
|
|
74
93
|
return __TS__ArrayEvery(
|
package/functions/tears.lua
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
+
--- - The `EntityPlayer` object stores a player's tear rate in the `MaxFireDelay` attribute. This is
|
|
3
|
+
-- equivalent to how many tears the player can shoot per frame.
|
|
4
|
+
-- - If you already have a "tears" stat and you want to convert it back to MaxFireDelay, then use
|
|
5
|
+
-- this function.
|
|
6
|
+
-- - In this context, the "tears stat" represents what is shown on the in-game stat UI.
|
|
2
7
|
function ____exports.getFireDelay(self, tearsStat)
|
|
3
8
|
return math.max(30 / tearsStat - 1, -0.9999)
|
|
4
9
|
end
|
|
10
|
+
--- - The `EntityPlayer` object stores a player's tear rate in the `MaxFireDelay` attribute. This is
|
|
11
|
+
-- equivalent to how many tears the player can shoot per frame.
|
|
12
|
+
-- - If you want to convert this to the "tears" stat that is shown on the in-game stat UI, then use
|
|
13
|
+
-- this function.
|
|
5
14
|
function ____exports.getTearsStat(self, fireDelay)
|
|
6
15
|
return 30 / (fireDelay + 1)
|
|
7
16
|
end
|
|
17
|
+
--- - Converts the specified amount of tears stat into MaxFireDelay and adds it to the player.
|
|
18
|
+
-- - This function should only be used inside the EvaluateCache callback.
|
|
19
|
+
-- - In this context, the "tears stat" represents what is shown on the in-game stat UI.
|
|
8
20
|
function ____exports.addTearsStat(self, player, tearsStat)
|
|
9
21
|
local existingTearsStat = ____exports.getTearsStat(nil, player.MaxFireDelay)
|
|
10
22
|
local newTearsStat = existingTearsStat + tearsStat
|
|
@@ -36,6 +36,14 @@ local TRANSFORMATION_TO_TAG_MAP = __TS__New(Map, {
|
|
|
36
36
|
{PlayerForm.SPIDER_BABY, ItemConfigTag.SPIDER}
|
|
37
37
|
})
|
|
38
38
|
local TRANSFORMATIONS_THAT_GRANT_FLYING = __TS__New(Set, {PlayerForm.GUPPY, PlayerForm.BEELZEBUB, PlayerForm.SERAPHIM, PlayerForm.LEVIATHAN})
|
|
39
|
+
--- Helper function to get all of the collectible types in the game that count towards a particular
|
|
40
|
+
-- transformation.
|
|
41
|
+
--
|
|
42
|
+
-- For example, to get all of the collectible types that count towards Guppy:
|
|
43
|
+
--
|
|
44
|
+
-- ```ts
|
|
45
|
+
-- const guppyCollectibleTypes = getCollectibleTypesForTransformation(PlayerForm.GUPPY);
|
|
46
|
+
-- ```
|
|
39
47
|
function ____exports.getCollectibleTypesForTransformation(self, playerForm)
|
|
40
48
|
local itemConfigTag = TRANSFORMATION_TO_TAG_MAP:get(playerForm)
|
|
41
49
|
if itemConfigTag == nil then
|
|
@@ -43,6 +51,7 @@ function ____exports.getCollectibleTypesForTransformation(self, playerForm)
|
|
|
43
51
|
end
|
|
44
52
|
return getCollectibleTypesWithTag(nil, itemConfigTag)
|
|
45
53
|
end
|
|
54
|
+
--- Returns the number of items that a player has towards a particular transformation.
|
|
46
55
|
function ____exports.getPlayerNumCollectiblesForTransformation(self, player, playerForm)
|
|
47
56
|
local collectibleTypes = ____exports.getCollectibleTypesForTransformation(nil, playerForm)
|
|
48
57
|
return getPlayerCollectibleCount(
|
|
@@ -51,6 +60,7 @@ function ____exports.getPlayerNumCollectiblesForTransformation(self, player, pla
|
|
|
51
60
|
__TS__Spread(collectibleTypes:values())
|
|
52
61
|
)
|
|
53
62
|
end
|
|
63
|
+
--- Returns a set of the player's current transformations.
|
|
54
64
|
function ____exports.getPlayerTransformations(self, player)
|
|
55
65
|
local transformations = __TS__New(Set)
|
|
56
66
|
for ____, playerForm in ipairs(getEnumValues(nil, PlayerForm)) do
|
|
@@ -60,6 +70,14 @@ function ____exports.getPlayerTransformations(self, player)
|
|
|
60
70
|
end
|
|
61
71
|
return transformations
|
|
62
72
|
end
|
|
73
|
+
--- Helper function to get a transformation name from a PlayerForm enum.
|
|
74
|
+
--
|
|
75
|
+
-- For example:
|
|
76
|
+
--
|
|
77
|
+
-- ```ts
|
|
78
|
+
-- const transformationName = getTransformationName(PlayerForm.LORD_OF_THE_FLIES);
|
|
79
|
+
-- // transformationName is "Beelzebub"
|
|
80
|
+
-- ```
|
|
63
81
|
function ____exports.getTransformationName(self, playerForm)
|
|
64
82
|
local transformationName = TRANSFORMATION_NAMES[playerForm]
|
|
65
83
|
return transformationName == nil and DEFAULT_TRANSFORMATION_NAME or transformationName
|