isaacscript-common 6.3.0 → 6.5.1

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.
Files changed (78) hide show
  1. package/cachedClasses.d.ts +15 -0
  2. package/cachedClasses.lua +20 -0
  3. package/constants.d.ts +17 -4
  4. package/constants.lua +13 -4
  5. package/enums/DecorationVariant.d.ts +9 -0
  6. package/enums/DecorationVariant.lua +7 -0
  7. package/enums/RockAltType.d.ts +7 -0
  8. package/enums/RockAltType.lua +13 -0
  9. package/features/customGridEntity.d.ts +2 -2
  10. package/features/customGridEntity.lua +7 -5
  11. package/features/customStage/backdrop.lua +11 -18
  12. package/features/customStage/customStageConstants.d.ts +1 -0
  13. package/features/customStage/customStageConstants.lua +3 -0
  14. package/features/customStage/exports.d.ts +27 -0
  15. package/features/customStage/exports.lua +33 -3
  16. package/features/customStage/gridEntities.d.ts +18 -0
  17. package/features/customStage/gridEntities.lua +215 -0
  18. package/features/customStage/init.lua +57 -8
  19. package/features/customStage/shadows.d.ts +3 -0
  20. package/features/customStage/shadows.lua +58 -0
  21. package/features/customStage/streakText.d.ts +3 -0
  22. package/features/customStage/streakText.lua +29 -0
  23. package/features/customStage/v.d.ts +6 -0
  24. package/features/customStage/v.lua +3 -1
  25. package/features/customStage/versusScreen.d.ts +3 -0
  26. package/features/customStage/versusScreen.lua +201 -0
  27. package/features/deployJSONRoom.lua +6 -2
  28. package/features/extraConsoleCommands/init.lua +2 -0
  29. package/features/extraConsoleCommands/listCommands.d.ts +9 -2
  30. package/features/extraConsoleCommands/listCommands.lua +20 -4
  31. package/features/saveDataManager/exports.lua +2 -2
  32. package/features/saveDataManager/load.lua +3 -3
  33. package/features/saveDataManager/main.lua +3 -3
  34. package/features/saveDataManager/merge.lua +2 -2
  35. package/features/saveDataManager/save.lua +3 -3
  36. package/features/saveDataManager/{constants.d.ts → saveDataManagerConstants.d.ts} +0 -0
  37. package/features/saveDataManager/{constants.lua → saveDataManagerConstants.lua} +0 -0
  38. package/functions/color.d.ts +0 -2
  39. package/functions/color.lua +0 -4
  40. package/functions/deepCopy.lua +2 -2
  41. package/functions/doors.d.ts +10 -5
  42. package/functions/doors.lua +20 -17
  43. package/functions/entity.d.ts +5 -0
  44. package/functions/entity.lua +13 -0
  45. package/functions/gridEntity.d.ts +39 -0
  46. package/functions/gridEntity.lua +83 -2
  47. package/functions/kColor.d.ts +0 -2
  48. package/functions/kColor.lua +0 -4
  49. package/functions/log.lua +2 -1
  50. package/functions/pickups.d.ts +9 -9
  51. package/functions/run.d.ts +7 -0
  52. package/functions/run.lua +16 -4
  53. package/functions/ui.d.ts +2 -0
  54. package/functions/ui.lua +8 -0
  55. package/functions/utils.d.ts +6 -4
  56. package/functions/utils.lua +6 -4
  57. package/interfaces/CustomStageLua.d.ts +271 -63
  58. package/objects/backdropTypeToRockAltType.d.ts +6 -0
  59. package/objects/backdropTypeToRockAltType.lua +69 -0
  60. package/objects/bossNamePNGFileNames.d.ts +5 -0
  61. package/objects/bossNamePNGFileNames.lua +108 -0
  62. package/objects/bossPortraitPNGFileNames.d.ts +5 -0
  63. package/objects/bossPortraitPNGFileNames.lua +108 -0
  64. package/objects/colors.d.ts +15 -8
  65. package/objects/colors.lua +9 -2
  66. package/objects/playerNamePNGFileNames.d.ts +5 -0
  67. package/objects/playerNamePNGFileNames.lua +49 -0
  68. package/objects/playerPortraitPNGFileNames.d.ts +5 -0
  69. package/objects/playerPortraitPNGFileNames.lua +49 -0
  70. package/objects/versusScreenBackgroundColors.d.ts +5 -0
  71. package/objects/versusScreenBackgroundColors.lua +38 -0
  72. package/objects/versusScreenDirtSpotColors.d.ts +5 -0
  73. package/objects/versusScreenDirtSpotColors.lua +38 -0
  74. package/package.json +2 -2
  75. package/features/customStage/boss.d.ts +0 -2
  76. package/features/customStage/boss.lua +0 -74
  77. package/features/customStage/stageAPIBoss.d.ts +0 -29
  78. package/features/customStage/stageAPIBoss.lua +0 -9
@@ -13,9 +13,9 @@ local ____log = require("functions.log")
13
13
  local log = ____log.log
14
14
  local ____table = require("functions.table")
15
15
  local iterateTableInOrder = ____table.iterateTableInOrder
16
- local ____constants = require("features.saveDataManager.constants")
17
- local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
18
- local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
16
+ local ____saveDataManagerConstants = require("features.saveDataManager.saveDataManagerConstants")
17
+ local SAVE_DATA_MANAGER_DEBUG = ____saveDataManagerConstants.SAVE_DATA_MANAGER_DEBUG
18
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____saveDataManagerConstants.SAVE_DATA_MANAGER_FEATURE_NAME
19
19
  function getAllSaveDataToWriteToDisk(self, saveDataMap, saveDataConditionalFuncMap)
20
20
  local allSaveData = {}
21
21
  iterateTableInOrder(
@@ -19,8 +19,6 @@ export declare function colorEquals(color1: Color, color2: Color): boolean;
19
19
  */
20
20
  export declare function copyColor<C extends Color | SerializedColor, S extends SerializationType>(color: C, serializationType: S): CopyColorReturn[S];
21
21
  export declare function copyColor<C extends Color | SerializedColor>(color: C): CopyColorReturn[SerializationType.NONE];
22
- /** Returns `Color(1, 1, 1)`. */
23
- export declare function getDefaultColor(): Color;
24
22
  /** Helper function to check if something is an instantiated Color object. */
25
23
  export declare function isColor(object: unknown): object is Color;
26
24
  /**
@@ -104,10 +104,6 @@ function ____exports.copyColor(self, color, serializationType)
104
104
  end
105
105
  until true
106
106
  end
107
- --- Returns `Color(1, 1, 1)`.
108
- function ____exports.getDefaultColor(self)
109
- return Color(1, 1, 1)
110
- end
111
107
  --- Used to determine is the given table is a serialized `Color` object created by the save data
112
108
  -- manager and/or the `deepCopy` function.
113
109
  function ____exports.isSerializedColor(self, object)
@@ -15,8 +15,8 @@ local ____SerializationBrand = require("enums.private.SerializationBrand")
15
15
  local SerializationBrand = ____SerializationBrand.SerializationBrand
16
16
  local ____SerializationType = require("enums.SerializationType")
17
17
  local SerializationType = ____SerializationType.SerializationType
18
- local ____constants = require("features.saveDataManager.constants")
19
- local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
18
+ local ____saveDataManagerConstants = require("features.saveDataManager.saveDataManagerConstants")
19
+ local SAVE_DATA_MANAGER_DEBUG = ____saveDataManagerConstants.SAVE_DATA_MANAGER_DEBUG
20
20
  local ____serializationBrand = require("features.saveDataManager.serializationBrand")
21
21
  local isSerializationBrand = ____serializationBrand.isSerializationBrand
22
22
  local ____array = require("functions.array")
@@ -70,31 +70,36 @@ export declare function isDevilRoomDoor(door: GridEntityDoor): boolean;
70
70
  export declare function isDoorSlotInRoomShape(doorSlot: DoorSlot, roomShape: RoomShape): boolean;
71
71
  /**
72
72
  * This refers to the Repentance door that spawns in a boss room after defeating the boss. You have
73
- * to spend one key to open it. It has a sprite filename of "gfx/grid/Door_Downpour.anm2".
73
+ * to spend one key to open it. It has a sprite filename of "gfx/grid/door_downpour.anm2".
74
74
  */
75
75
  export declare function isDoorToDownpour(door: GridEntityDoor): boolean;
76
76
  /**
77
77
  * This refers to the Repentance door that spawns in a boss room after defeating the boss. You have
78
- * to spend two hearts to open it. It has a sprite filename of "gfx/grid/Door_Mausoleum.anm2".
78
+ * to spend two hearts to open it. It has a sprite filename of "gfx/grid/door_mausoleum.anm2".
79
79
  */
80
80
  export declare function isDoorToMausoleum(door: GridEntityDoor): boolean;
81
81
  /**
82
82
  * This refers to the "strange door" located on the first room of Depths 2. You open it with either
83
- * a Polaroid or a Negative. It has a sprite filename of "gfx/grid/Door_Mausoleum_Alt.anm2".
83
+ * a Polaroid or a Negative. It has a sprite filename of "gfx/grid/door_mausoleum_alt.anm2".
84
84
  */
85
85
  export declare function isDoorToMausoleumAscent(door: GridEntityDoor): boolean;
86
86
  /**
87
87
  * This refers to the Repentance door that spawns in a boss room after defeating the boss. You have
88
- * to spend two bombs to open it. It has a sprite filename of "gfx/grid/Door_Mines.anm2".
88
+ * to spend two bombs to open it. It has a sprite filename of "gfx/grid/door_mines.anm2".
89
89
  */
90
90
  export declare function isDoorToMines(door: GridEntityDoor): boolean;
91
91
  /**
92
92
  * This refers to the Repentance door that spawns after defeating Mom. You open it with the
93
- * completed knife. It has a sprite filename of "gfx/grid/Door_MomsHeart.anm2".
93
+ * completed knife. It has a sprite filename of "gfx/grid/door_momsheart.anm2".
94
94
  */
95
95
  export declare function isDoorToMomsHeart(door: GridEntityDoor): boolean;
96
96
  export declare function isHiddenSecretRoomDoor(door: GridEntityDoor): boolean;
97
97
  export declare function isRepentanceDoor(door: GridEntityDoor): boolean;
98
+ /**
99
+ * This refers to the hole in the wall that appears after bombing the entrance to a secret room.
100
+ * Note that the door still exists before it has been bombed open. It has a sprite filename of
101
+ * "gfx/grid/door_08_holeinwall.anm2".
102
+ */
98
103
  export declare function isSecretRoomDoor(door: GridEntityDoor): boolean;
99
104
  /**
100
105
  * Helper function to reset an unlocked door back to a locked state. Doing this is non-trivial
@@ -77,10 +77,13 @@ end
77
77
  function ____exports.isRepentanceDoor(self, door)
78
78
  return door.TargetRoomIndex == GridRoom.SECRET_EXIT
79
79
  end
80
+ --- This refers to the hole in the wall that appears after bombing the entrance to a secret room.
81
+ -- Note that the door still exists before it has been bombed open. It has a sprite filename of
82
+ -- "gfx/grid/door_08_holeinwall.anm2".
80
83
  function ____exports.isSecretRoomDoor(self, door)
81
84
  local sprite = door:GetSprite()
82
- local filename = sprite:GetFilename()
83
- return filename == "gfx/grid/Door_08_HoleInWall.anm2"
85
+ local fileName = sprite:GetFilename()
86
+ return string.lower(fileName) == "gfx/grid/door_08_holeinwall.anm2"
84
87
  end
85
88
  --- Helper function to remove a single door.
86
89
  function ____exports.removeDoor(self, door)
@@ -234,54 +237,54 @@ function ____exports.isDoorSlotInRoomShape(self, doorSlot, roomShape)
234
237
  return doorSlots:has(doorSlot)
235
238
  end
236
239
  --- This refers to the Repentance door that spawns in a boss room after defeating the boss. You have
237
- -- to spend one key to open it. It has a sprite filename of "gfx/grid/Door_Downpour.anm2".
240
+ -- to spend one key to open it. It has a sprite filename of "gfx/grid/door_downpour.anm2".
238
241
  function ____exports.isDoorToDownpour(self, door)
239
242
  if not ____exports.isRepentanceDoor(nil, door) then
240
243
  return false
241
244
  end
242
245
  local sprite = door:GetSprite()
243
- local filename = sprite:GetFilename()
244
- return filename == "gfx/grid/Door_Downpour.anm2"
246
+ local fileName = sprite:GetFilename()
247
+ return string.lower(fileName) == "gfx/grid/door_downpour.anm2"
245
248
  end
246
249
  --- This refers to the Repentance door that spawns in a boss room after defeating the boss. You have
247
- -- to spend two hearts to open it. It has a sprite filename of "gfx/grid/Door_Mausoleum.anm2".
250
+ -- to spend two hearts to open it. It has a sprite filename of "gfx/grid/door_mausoleum.anm2".
248
251
  function ____exports.isDoorToMausoleum(self, door)
249
252
  if not ____exports.isRepentanceDoor(nil, door) then
250
253
  return false
251
254
  end
252
255
  local sprite = door:GetSprite()
253
- local filename = sprite:GetFilename()
254
- return filename == "gfx/grid/Door_Mausoleum.anm2"
256
+ local fileName = sprite:GetFilename()
257
+ return string.lower(fileName) == "gfx/grid/door_mausoleum.anm2"
255
258
  end
256
259
  --- This refers to the "strange door" located on the first room of Depths 2. You open it with either
257
- -- a Polaroid or a Negative. It has a sprite filename of "gfx/grid/Door_Mausoleum_Alt.anm2".
260
+ -- a Polaroid or a Negative. It has a sprite filename of "gfx/grid/door_mausoleum_alt.anm2".
258
261
  function ____exports.isDoorToMausoleumAscent(self, door)
259
262
  if not ____exports.isRepentanceDoor(nil, door) then
260
263
  return false
261
264
  end
262
265
  local sprite = door:GetSprite()
263
- local filename = sprite:GetFilename()
264
- return filename == "gfx/grid/Door_Mausoleum_Alt.anm2"
266
+ local fileName = sprite:GetFilename()
267
+ return string.lower(fileName) == "gfx/grid/door_mausoleum_alt.anm2"
265
268
  end
266
269
  --- This refers to the Repentance door that spawns in a boss room after defeating the boss. You have
267
- -- to spend two bombs to open it. It has a sprite filename of "gfx/grid/Door_Mines.anm2".
270
+ -- to spend two bombs to open it. It has a sprite filename of "gfx/grid/door_mines.anm2".
268
271
  function ____exports.isDoorToMines(self, door)
269
272
  if not ____exports.isRepentanceDoor(nil, door) then
270
273
  return false
271
274
  end
272
275
  local sprite = door:GetSprite()
273
- local filename = sprite:GetFilename()
274
- return filename == "gfx/grid/Door_Mines.anm2"
276
+ local fileName = sprite:GetFilename()
277
+ return string.lower(fileName) == "gfx/grid/door_mines.anm2"
275
278
  end
276
279
  --- This refers to the Repentance door that spawns after defeating Mom. You open it with the
277
- -- completed knife. It has a sprite filename of "gfx/grid/Door_MomsHeart.anm2".
280
+ -- completed knife. It has a sprite filename of "gfx/grid/door_momsheart.anm2".
278
281
  function ____exports.isDoorToMomsHeart(self, door)
279
282
  if not ____exports.isRepentanceDoor(nil, door) then
280
283
  return false
281
284
  end
282
285
  local sprite = door:GetSprite()
283
- local filename = sprite:GetFilename()
284
- return filename == "gfx/grid/Door_MomsHeart.anm2"
286
+ local fileName = sprite:GetFilename()
287
+ return string.lower(fileName) == "gfx/grid/door_momsheart.anm2"
285
288
  end
286
289
  function ____exports.isHiddenSecretRoomDoor(self, door)
287
290
  local sprite = door:GetSprite()
@@ -72,6 +72,11 @@ export declare function getEntities(entityType?: EntityType, variant?: number, s
72
72
  export declare function getEntityFields(entity: Entity): LuaTable<string, boolean | number | string>;
73
73
  /** Helper function to return a string containing the entity's type, variant, and sub-type. */
74
74
  export declare function getEntityID(entity: Entity): string;
75
+ /**
76
+ * Helper function to return a formatted string in the format returned by the `getEntityID`
77
+ * function.
78
+ */
79
+ export declare function getEntityIDFromConstituents(entityType: EntityType, variant: int, subType: int): string;
75
80
  /**
76
81
  * Helper function to compare two different arrays of entities. Returns the entities that are in the
77
82
  * second array but not in the first array.
@@ -202,6 +202,11 @@ end
202
202
  function ____exports.getEntityID(self, entity)
203
203
  return (((tostring(entity.Type) .. ".") .. tostring(entity.Variant)) .. ".") .. tostring(entity.SubType)
204
204
  end
205
+ --- Helper function to return a formatted string in the format returned by the `getEntityID`
206
+ -- function.
207
+ function ____exports.getEntityIDFromConstituents(self, entityType, variant, subType)
208
+ return (((tostring(entityType) .. ".") .. tostring(variant)) .. ".") .. tostring(subType)
209
+ end
205
210
  --- Helper function to compare two different arrays of entities. Returns the entities that are in the
206
211
  -- second array but not in the first array.
207
212
  function ____exports.getFilteredNewEntities(self, oldEntities, newEntities)
@@ -349,6 +354,14 @@ function ____exports.spawn(self, entityType, variant, subType, position, velocit
349
354
  if seedOrRNG == nil then
350
355
  seedOrRNG = nil
351
356
  end
357
+ if position == nil then
358
+ local entityID = ____exports.getEntityIDFromConstituents(nil, entityType, variant, subType)
359
+ error(("Failed to spawn entity " .. entityID) .. " since an undefined position was passed to the \"spawn\" function.")
360
+ end
361
+ if velocity == nil then
362
+ local entityID = ____exports.getEntityIDFromConstituents(nil, entityType, variant, subType)
363
+ error(("Failed to spawn entity " .. entityID) .. " since an undefined velocity was passed to the \"spawn\" function.")
364
+ end
352
365
  if seedOrRNG == nil then
353
366
  return Isaac.Spawn(
354
367
  entityType,
@@ -1,4 +1,5 @@
1
1
  import { GridEntityType, GridEntityXMLType } from "isaac-typescript-definitions";
2
+ import { RockAltType } from "../enums/RockAltType";
2
3
  /**
3
4
  * Helper function to convert the grid entity type found in a room XML file to the corresponding
4
5
  * grid entity type and variant normally used by the game. For example, a rock is represented as
@@ -61,11 +62,31 @@ export declare function getGridEntitiesExcept(...gridEntityTypes: GridEntityType
61
62
  export declare function getGridEntitiesMap(...gridEntityTypes: GridEntityType[]): Map<int, GridEntity>;
62
63
  /** Helper function to return a string containing the grid entity's type and variant. */
63
64
  export declare function getGridEntityID(gridEntity: GridEntity): string;
65
+ /**
66
+ * Helper function to return a formatted string in the format returned by the `getGridEntityID`
67
+ * function.
68
+ */
69
+ export declare function getGridEntityIDFromConstituents(gridEntityType: GridEntityType, variant: int): string;
64
70
  /**
65
71
  * Helper function to get all of the grid entities in the room that specifically match the type and
66
72
  * variant provided.
67
73
  */
68
74
  export declare function getMatchingGridEntities(gridEntityType: GridEntityType, variant: int): GridEntity[];
75
+ /**
76
+ * Helper function to get the alternate rock type (i.e. urn, mushroom, etc.) that the current room
77
+ * will have.
78
+ *
79
+ * The rock type is based on the backdrop of the room.
80
+ *
81
+ * For example, if you change the backdrop of the starting room of the run to `BackdropType.CAVES`,
82
+ * and then spawn `GridEntityType.ROCK_ALT`, it will be a mushroom instead of an urn. Additionally,
83
+ * if it is destroyed, it will generate mushroom-appropriate rewards.
84
+ *
85
+ * On the other hand, if an urn is spawned first before the backdrop is changed to
86
+ * `BackdropType.CAVES`, the graphic of the urn will not switch to a mushroom. However, when
87
+ * destroyed, the urn will still generate mushroom-appropriate rewards.
88
+ */
89
+ export declare function getRockAltType(): RockAltType;
69
90
  export declare function getSurroundingGridEntities(gridEntity: GridEntity): GridEntity[];
70
91
  export declare function getTopLeftWall(): GridEntity | undefined;
71
92
  /**
@@ -173,6 +194,24 @@ export declare function spawnGrid(gridEntityType: GridEntityType, gridIndexOrPos
173
194
  * - allows you to specify the grid index or the position
174
195
  */
175
196
  export declare function spawnGridWithVariant(gridEntityType: GridEntityType, variant: int, gridIndexOrPosition: int | Vector): GridEntity | undefined;
197
+ /**
198
+ * Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
199
+ * breaks.
200
+ *
201
+ * Note that most of the time, this function will do nothing, similar to how most of the time, when
202
+ * an individual urn is destroyed, nothing will spawn.
203
+ *
204
+ * The logic in this function is based on the rewards listed on the wiki:
205
+ * https://bindingofisaacrebirth.fandom.com/wiki/Rocks
206
+ *
207
+ * @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
208
+ * at spawning coins and spiders.
209
+ * @param _seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
210
+ * the `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally,
211
+ * you should pass the `InitSeed` of the grid entity that was broken.
212
+ * @returns Whether or not this function spawned something.
213
+ */
214
+ export declare function spawnRockAltReward(rockAltType: RockAltType, _seedOrRNG?: Seed | RNG): boolean;
176
215
  /**
177
216
  * Helper function to spawn a Void Portal. This is more complicated than simply spawning a trapdoor
178
217
  * with the appropriate variant, as the game does not give it the correct sprite automatically.
@@ -15,6 +15,8 @@ local ____cachedClasses = require("cachedClasses")
15
15
  local game = ____cachedClasses.game
16
16
  local ____constants = require("constants")
17
17
  local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
18
+ local ____RockAltType = require("enums.RockAltType")
19
+ local RockAltType = ____RockAltType.RockAltType
18
20
  local ____gridEntityTypeToBrokenStateMap = require("maps.gridEntityTypeToBrokenStateMap")
19
21
  local GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP = ____gridEntityTypeToBrokenStateMap.GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP
20
22
  local ____gridEntityXMLMap = require("maps.gridEntityXMLMap")
@@ -22,8 +24,12 @@ local GRID_ENTITY_XML_MAP = ____gridEntityXMLMap.GRID_ENTITY_XML_MAP
22
24
  local ____roomShapeToTopLeftWallGridIndexMap = require("maps.roomShapeToTopLeftWallGridIndexMap")
23
25
  local DEFAULT_TOP_LEFT_WALL_GRID_INDEX = ____roomShapeToTopLeftWallGridIndexMap.DEFAULT_TOP_LEFT_WALL_GRID_INDEX
24
26
  local ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP = ____roomShapeToTopLeftWallGridIndexMap.ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP
27
+ local ____backdropTypeToRockAltType = require("objects.backdropTypeToRockAltType")
28
+ local BACKDROP_TYPE_TO_ROCK_ALT_TYPE = ____backdropTypeToRockAltType.BACKDROP_TYPE_TO_ROCK_ALT_TYPE
25
29
  local ____math = require("functions.math")
26
30
  local isCircleIntersectingRectangle = ____math.isCircleIntersectingRectangle
31
+ local ____rng = require("functions.rng")
32
+ local getRandomSeed = ____rng.getRandomSeed
27
33
  local ____rooms = require("functions.rooms")
28
34
  local roomUpdateSafe = ____rooms.roomUpdateSafe
29
35
  local ____sprite = require("functions.sprite")
@@ -238,8 +244,13 @@ end
238
244
  --- Helper function to return a string containing the grid entity's type and variant.
239
245
  function ____exports.getGridEntityID(self, gridEntity)
240
246
  local gridEntityType = gridEntity:GetType()
241
- local gridEntityVariant = gridEntity:GetVariant()
242
- return (tostring(gridEntityType) .. ".") .. tostring(gridEntityVariant)
247
+ local variant = gridEntity:GetVariant()
248
+ return (tostring(gridEntityType) .. ".") .. tostring(variant)
249
+ end
250
+ --- Helper function to return a formatted string in the format returned by the `getGridEntityID`
251
+ -- function.
252
+ function ____exports.getGridEntityIDFromConstituents(self, gridEntityType, variant)
253
+ return (tostring(gridEntityType) .. ".") .. tostring(variant)
243
254
  end
244
255
  --- Helper function to get all of the grid entities in the room that specifically match the type and
245
256
  -- variant provided.
@@ -250,6 +261,23 @@ function ____exports.getMatchingGridEntities(self, gridEntityType, variant)
250
261
  function(____, gridEntity) return gridEntity:GetVariant() == variant end
251
262
  )
252
263
  end
264
+ --- Helper function to get the alternate rock type (i.e. urn, mushroom, etc.) that the current room
265
+ -- will have.
266
+ --
267
+ -- The rock type is based on the backdrop of the room.
268
+ --
269
+ -- For example, if you change the backdrop of the starting room of the run to `BackdropType.CAVES`,
270
+ -- and then spawn `GridEntityType.ROCK_ALT`, it will be a mushroom instead of an urn. Additionally,
271
+ -- if it is destroyed, it will generate mushroom-appropriate rewards.
272
+ --
273
+ -- On the other hand, if an urn is spawned first before the backdrop is changed to
274
+ -- `BackdropType.CAVES`, the graphic of the urn will not switch to a mushroom. However, when
275
+ -- destroyed, the urn will still generate mushroom-appropriate rewards.
276
+ function ____exports.getRockAltType(self)
277
+ local room = game:GetRoom()
278
+ local backdropType = room:GetBackdropType()
279
+ return BACKDROP_TYPE_TO_ROCK_ALT_TYPE[backdropType]
280
+ end
253
281
  function ____exports.getSurroundingGridEntities(self, gridEntity)
254
282
  local room = game:GetRoom()
255
283
  local gridWidth = room:GetGridWidth()
@@ -395,6 +423,59 @@ end
395
423
  function ____exports.spawnGrid(self, gridEntityType, gridIndexOrPosition)
396
424
  return ____exports.spawnGridWithVariant(nil, gridEntityType, 0, gridIndexOrPosition)
397
425
  end
426
+ --- Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
427
+ -- breaks.
428
+ --
429
+ -- Note that most of the time, this function will do nothing, similar to how most of the time, when
430
+ -- an individual urn is destroyed, nothing will spawn.
431
+ --
432
+ -- The logic in this function is based on the rewards listed on the wiki:
433
+ -- https://bindingofisaacrebirth.fandom.com/wiki/Rocks
434
+ --
435
+ -- @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
436
+ -- at spawning coins and spiders.
437
+ -- @param _seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
438
+ -- the `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally,
439
+ -- you should pass the `InitSeed` of the grid entity that was broken.
440
+ -- @returns Whether or not this function spawned something.
441
+ function ____exports.spawnRockAltReward(self, rockAltType, _seedOrRNG)
442
+ if _seedOrRNG == nil then
443
+ _seedOrRNG = getRandomSeed(nil)
444
+ end
445
+ repeat
446
+ local ____switch56 = rockAltType
447
+ local ____cond56 = ____switch56 == RockAltType.URN
448
+ if ____cond56 then
449
+ do
450
+ return false
451
+ end
452
+ end
453
+ ____cond56 = ____cond56 or ____switch56 == RockAltType.MUSHROOM
454
+ if ____cond56 then
455
+ do
456
+ return false
457
+ end
458
+ end
459
+ ____cond56 = ____cond56 or ____switch56 == RockAltType.SKULL
460
+ if ____cond56 then
461
+ do
462
+ return false
463
+ end
464
+ end
465
+ ____cond56 = ____cond56 or ____switch56 == RockAltType.POLYP
466
+ if ____cond56 then
467
+ do
468
+ return false
469
+ end
470
+ end
471
+ ____cond56 = ____cond56 or ____switch56 == RockAltType.BUCKET
472
+ if ____cond56 then
473
+ do
474
+ return false
475
+ end
476
+ end
477
+ until true
478
+ end
398
479
  --- Helper function to spawn a Void Portal. This is more complicated than simply spawning a trapdoor
399
480
  -- with the appropriate variant, as the game does not give it the correct sprite automatically.
400
481
  function ____exports.spawnVoidPortal(self, gridIndex)
@@ -18,8 +18,6 @@ interface CopyKColorReturn {
18
18
  */
19
19
  export declare function copyKColor<K extends KColor | SerializedKColor, S extends SerializationType>(kColor: K, serializationType: S): CopyKColorReturn[S];
20
20
  export declare function copyKColor<K extends KColor | SerializedKColor>(kColor: K): CopyKColorReturn[SerializationType.NONE];
21
- /** Returns `KColor(1, 1, 1, 1)`. */
22
- export declare function getDefaultKColor(): KColor;
23
21
  /** Helper function to check if something is an instantiated KColor object. */
24
22
  export declare function isKColor(object: unknown): object is KColor;
25
23
  /**
@@ -80,10 +80,6 @@ function ____exports.copyKColor(self, kColor, serializationType)
80
80
  end
81
81
  until true
82
82
  end
83
- --- Returns `KColor(1, 1, 1, 1)`.
84
- function ____exports.getDefaultKColor(self)
85
- return KColor(1, 1, 1, 1)
86
- end
87
83
  --- Used to determine is the given table is a serialized `KColor` object created by the save data
88
84
  -- manager and/or the `deepCopy` function.
89
85
  function ____exports.isSerializedKColor(self, object)
package/functions/log.lua CHANGED
@@ -247,7 +247,8 @@ function ____exports.logEntityFlags(flags)
247
247
  ____exports.logFlags(flags, EntityFlag, "entity")
248
248
  end
249
249
  function ____exports.logEntityID(entity)
250
- ____exports.log((((("Entity: " .. tostring(entity.Type)) .. ".") .. tostring(entity.Variant)) .. ".") .. tostring(entity.SubType))
250
+ local entityID = getEntityID(nil, entity)
251
+ ____exports.log("Entity: " .. entityID)
251
252
  end
252
253
  --- Helper function to log an error message and also print it to the console for better visibility.
253
254
  --
@@ -1,29 +1,29 @@
1
1
  import { BatterySubType, Card, CoinSubType, CollectibleType, HeartSubType, KeySubType, PillColor, SackSubType, TrinketType } from "isaac-typescript-definitions";
2
2
  /** Helper function to get all of the battery entities in the room. */
3
- export declare function getBatteries(matchingSubType?: number): EntityPickupBattery[];
3
+ export declare function getBatteries(matchingSubType?: BatterySubType | -1): EntityPickupBattery[];
4
4
  /** Helper function to get all of the card entities in the room. */
5
- export declare function getCards(matchingSubType?: number): EntityPickupCard[];
5
+ export declare function getCards(matchingSubType?: Card | -1): EntityPickupCard[];
6
6
  /**
7
7
  * Helper function to get the corresponding coin amount from a `CoinSubType`. Returns 1 for modded
8
8
  * sub-types.
9
9
  */
10
10
  export declare function getCoinValue(coinSubType: CoinSubType): int;
11
11
  /** Helper function to get all of the coin pickup entities in the room. */
12
- export declare function getCoins(matchingSubType?: number): EntityPickupCoin[];
12
+ export declare function getCoins(matchingSubType?: CoinSubType | -1): EntityPickupCoin[];
13
13
  /** Helper function to get all of the collectible entities in the room. */
14
- export declare function getCollectibles(matchingSubType?: number): EntityPickupCollectible[];
14
+ export declare function getCollectibles(matchingSubType?: CollectibleType | -1): EntityPickupCollectible[];
15
15
  /** Helper function to get all of the heart pickup entities in the room. */
16
- export declare function getHearts(matchingSubType?: number): EntityPickupHeart[];
16
+ export declare function getHearts(matchingSubType?: HeartSubType | -1): EntityPickupHeart[];
17
17
  /** Helper function to get all of the key pickup entities in the room. */
18
- export declare function getKeys(matchingSubType?: number): EntityPickupKey[];
18
+ export declare function getKeys(matchingSubType?: KeySubType | -1): EntityPickupKey[];
19
19
  /** Helper function to get all of the pill entities in the room. */
20
- export declare function getPills(matchingSubType?: number): EntityPickupPill[];
20
+ export declare function getPills(matchingSubType?: PillColor | -1): EntityPickupPill[];
21
21
  /** Helper function to get all of the red heart pickup entities in the room. */
22
22
  export declare function getRedHearts(): EntityPickupHeart[];
23
23
  /** Helper function to get all of the sack (i.e. grab bag) entities in the room. */
24
- export declare function getSacks(matchingSubType?: number): EntityPickupSack[];
24
+ export declare function getSacks(matchingSubType?: SackSubType | -1): EntityPickupSack[];
25
25
  /** Helper function to get all of the trinket entities in the room. */
26
- export declare function getTrinkets(matchingSubType?: number): EntityPickupTrinket[];
26
+ export declare function getTrinkets(matchingSubType?: TrinketType | -1): EntityPickupTrinket[];
27
27
  export declare function isChest(pickup: EntityPickup): boolean;
28
28
  export declare function isRedHeart(pickup: EntityPickup): boolean;
29
29
  /**
@@ -13,3 +13,10 @@ export declare function onSetSeed(): boolean;
13
13
  * You can optionally specify a `PlayerType` to restart the game as that character.
14
14
  */
15
15
  export declare function restart(character?: PlayerType): void;
16
+ /**
17
+ * Helper function to change the run status to that of an unseeded run with a new random seed.
18
+ *
19
+ * This is useful to revert the behavior where playing on a set and restarting the game will not
20
+ * take you to a new seed.
21
+ */
22
+ export declare function setUnseeded(): void;
package/functions/run.lua CHANGED
@@ -1,6 +1,7 @@
1
1
  local ____exports = {}
2
2
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
3
  local Challenge = ____isaac_2Dtypescript_2Ddefinitions.Challenge
4
+ local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
4
5
  local ____cachedClasses = require("cachedClasses")
5
6
  local game = ____cachedClasses.game
6
7
  local ____constantsFirstLast = require("constantsFirstLast")
@@ -23,14 +24,25 @@ end
23
24
  -- You can optionally specify a `PlayerType` to restart the game as that character.
24
25
  function ____exports.restart(self, character)
25
26
  if character == nil then
26
- log("Restarting.")
27
- Isaac.ExecuteCommand("restart")
27
+ local command = "restart"
28
+ log("Restarting the run with a console command of: " .. command)
29
+ Isaac.ExecuteCommand(command)
28
30
  return
29
31
  end
30
32
  if character < FIRST_CHARACTER then
31
33
  error(("Restarting as a character of " .. tostring(character)) .. " would crash the game.")
32
34
  end
33
- log("Restarting as character: " .. tostring(character))
34
- Isaac.ExecuteCommand("restart " .. tostring(character))
35
+ local command = "restart " .. tostring(character)
36
+ log((((("Restarting the run as PlayerType." .. tostring(PlayerType[character])) .. " (") .. tostring(character)) .. ") with a console command of: ") .. command)
37
+ Isaac.ExecuteCommand(command)
38
+ end
39
+ --- Helper function to change the run status to that of an unseeded run with a new random seed.
40
+ --
41
+ -- This is useful to revert the behavior where playing on a set and restarting the game will not
42
+ -- take you to a new seed.
43
+ function ____exports.setUnseeded(self)
44
+ local seeds = game:GetSeeds()
45
+ seeds:Reset()
46
+ seeds:Restart(Challenge.NULL)
35
47
  end
36
48
  return ____exports
package/functions/ui.d.ts CHANGED
@@ -23,9 +23,11 @@ export declare function getHeartRowLength(player: EntityPlayer): int;
23
23
  * combination with the the `getHUDOffsetVector` helper function.
24
24
  */
25
25
  export declare function getHeartsUIWidth(): int;
26
+ export declare function getScreenBottomCenterPos(): Vector;
26
27
  export declare function getScreenBottomLeftPos(): Vector;
27
28
  export declare function getScreenBottomRightPos(): Vector;
28
29
  export declare function getScreenCenterPos(): Vector;
30
+ export declare function getScreenTopCenterPos(): Vector;
29
31
  export declare function getScreenTopLeftPos(): Vector;
30
32
  export declare function getScreenTopRightPos(): Vector;
31
33
  /**
package/functions/ui.lua CHANGED
@@ -79,6 +79,10 @@ function ____exports.getHeartsUIWidth(self)
79
79
  end
80
80
  return width
81
81
  end
82
+ function ____exports.getScreenBottomCenterPos(self)
83
+ local bottomRight = ____exports.getScreenBottomRightPos(nil)
84
+ return Vector(bottomRight.X / 2, bottomRight.Y)
85
+ end
82
86
  function ____exports.getScreenBottomLeftPos(self)
83
87
  local bottomRight = ____exports.getScreenBottomRightPos(nil)
84
88
  return Vector(0, bottomRight.Y)
@@ -87,6 +91,10 @@ function ____exports.getScreenCenterPos(self)
87
91
  local bottomRight = ____exports.getScreenBottomRightPos(nil)
88
92
  return bottomRight / 2
89
93
  end
94
+ function ____exports.getScreenTopCenterPos(self)
95
+ local bottomRight = ____exports.getScreenBottomRightPos(nil)
96
+ return Vector(bottomRight.X / 2, 0)
97
+ end
90
98
  function ____exports.getScreenTopLeftPos(self)
91
99
  return copyVector(nil, VectorZero)
92
100
  end
@@ -4,9 +4,10 @@
4
4
  * Helper function to return an array with the elements from start to end. It is inclusive at the
5
5
  * start and exclusive at the end. (The "e" stands for exclusive.)
6
6
  *
7
- * For example, `erange(1, 3)` will return `[1, 2]`.
8
- *
9
7
  * If only one argument is specified, then it will assume that the start is 0.
8
+ *
9
+ * - For example, `erange(1, 3)` will return `[1, 2]`.
10
+ * - For example, `erange(2)` will return `[0, 1]`.
10
11
  */
11
12
  export declare function erange(start: int, end?: int): int[];
12
13
  /**
@@ -24,9 +25,10 @@ export declare function hexToKColor(hexString: string, alpha: float): KColor;
24
25
  * Helper function to return an array with the elements from start to end, inclusive. (The "i"
25
26
  * stands for inclusive.)
26
27
  *
27
- * For example, `irange(1, 3)` will return `[1, 2, 3]`.
28
- *
29
28
  * If only one argument is specified, then it will assume that the start is 0.
29
+ *
30
+ * - For example, `irange(1, 3)` will return `[1, 2, 3]`.
31
+ * - For example, `irange(2)` will return `[0, 1, 2]`.
30
32
  */
31
33
  export declare function irange(start: int, end?: int): int[];
32
34
  /**
@@ -12,9 +12,10 @@ local HEX_STRING_LENGTH = 6
12
12
  --- Helper function to return an array with the elements from start to end. It is inclusive at the
13
13
  -- start and exclusive at the end. (The "e" stands for exclusive.)
14
14
  --
15
- -- For example, `erange(1, 3)` will return `[1, 2]`.
16
- --
17
15
  -- If only one argument is specified, then it will assume that the start is 0.
16
+ --
17
+ -- - For example, `erange(1, 3)` will return `[1, 2]`.
18
+ -- - For example, `erange(2)` will return `[0, 1]`.
18
19
  function ____exports.erange(self, start, ____end)
19
20
  if ____end == nil then
20
21
  ____end = start
@@ -68,9 +69,10 @@ end
68
69
  --- Helper function to return an array with the elements from start to end, inclusive. (The "i"
69
70
  -- stands for inclusive.)
70
71
  --
71
- -- For example, `irange(1, 3)` will return `[1, 2, 3]`.
72
- --
73
72
  -- If only one argument is specified, then it will assume that the start is 0.
73
+ --
74
+ -- - For example, `irange(1, 3)` will return `[1, 2, 3]`.
75
+ -- - For example, `irange(2)` will return `[0, 1, 2]`.
74
76
  function ____exports.irange(self, start, ____end)
75
77
  if ____end == nil then
76
78
  ____end = start