isaacscript-common 1.0.498 → 1.0.502

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 (139) hide show
  1. package/dist/callbacks/customRevive.lua +9 -5
  2. package/dist/callbacks/itemPickup.lua +9 -5
  3. package/dist/callbacks/postBombInitLate.lua +8 -20
  4. package/dist/callbacks/postCursedTeleport.lua +5 -3
  5. package/dist/callbacks/postEffectInitLate.lua +8 -20
  6. package/dist/callbacks/postEsauJr.lua +9 -5
  7. package/dist/callbacks/postFamiliarInitLate.lua +6 -18
  8. package/dist/callbacks/postFlip.lua +9 -5
  9. package/dist/callbacks/postGridEntity.lua +13 -7
  10. package/dist/callbacks/postKnifeInitLate.lua +8 -20
  11. package/dist/callbacks/postLaserInitLate.lua +8 -20
  12. package/dist/callbacks/postNPCInitLate.lua +8 -20
  13. package/dist/callbacks/postNewRoomEarly.d.ts +2 -0
  14. package/dist/callbacks/postNewRoomEarly.lua +43 -0
  15. package/dist/callbacks/postPickupCollect.lua +5 -3
  16. package/dist/callbacks/postPickupInitLate.lua +8 -20
  17. package/dist/callbacks/postPlayerChangeHealth.lua +5 -3
  18. package/dist/callbacks/postPlayerChangeType.lua +5 -3
  19. package/dist/callbacks/postPlayerFatalDamage.lua +5 -3
  20. package/dist/callbacks/postPlayerInitLate.lua +5 -3
  21. package/dist/callbacks/postPlayerReordered.lua +16 -10
  22. package/dist/callbacks/postProjectileInitLate.lua +8 -20
  23. package/dist/callbacks/postPurchase.lua +11 -3
  24. package/dist/callbacks/postSacrifice.lua +5 -3
  25. package/dist/callbacks/postSlotInitUpdate.lua +9 -5
  26. package/dist/callbacks/postSlotRenderBroken.lua +9 -5
  27. package/dist/callbacks/postTearInitLate.lua +8 -20
  28. package/dist/callbacks/postTransformation.lua +5 -3
  29. package/dist/callbacks/reorderedCallbacks.lua +18 -12
  30. package/dist/callbacks/subscriptions/postBombInitLate.d.ts +3 -3
  31. package/dist/callbacks/subscriptions/postBombInitLate.lua +3 -3
  32. package/dist/callbacks/subscriptions/postCursedTeleport.d.ts +3 -3
  33. package/dist/callbacks/subscriptions/postCursedTeleport.lua +3 -3
  34. package/dist/callbacks/subscriptions/postCustomRevive.d.ts +3 -3
  35. package/dist/callbacks/subscriptions/postCustomRevive.lua +3 -3
  36. package/dist/callbacks/subscriptions/postEffectInitLate.d.ts +3 -3
  37. package/dist/callbacks/subscriptions/postEffectInitLate.lua +3 -3
  38. package/dist/callbacks/subscriptions/postEsauJr.d.ts +3 -3
  39. package/dist/callbacks/subscriptions/postEsauJr.lua +3 -3
  40. package/dist/callbacks/subscriptions/postFamiliarInitLate.d.ts +3 -3
  41. package/dist/callbacks/subscriptions/postFamiliarInitLate.lua +3 -3
  42. package/dist/callbacks/subscriptions/postFirstEsauJr.d.ts +3 -3
  43. package/dist/callbacks/subscriptions/postFirstEsauJr.lua +3 -3
  44. package/dist/callbacks/subscriptions/postFirstFlip.d.ts +3 -3
  45. package/dist/callbacks/subscriptions/postFirstFlip.lua +3 -3
  46. package/dist/callbacks/subscriptions/postFlip.d.ts +3 -3
  47. package/dist/callbacks/subscriptions/postFlip.lua +3 -3
  48. package/dist/callbacks/subscriptions/postGameStartedReordered.d.ts +3 -3
  49. package/dist/callbacks/subscriptions/postGameStartedReordered.lua +3 -3
  50. package/dist/callbacks/subscriptions/postGridEntityInit.d.ts +3 -3
  51. package/dist/callbacks/subscriptions/postGridEntityInit.lua +3 -3
  52. package/dist/callbacks/subscriptions/postGridEntityRemove.d.ts +3 -3
  53. package/dist/callbacks/subscriptions/postGridEntityRemove.lua +3 -3
  54. package/dist/callbacks/subscriptions/postGridEntityUpdate.d.ts +3 -3
  55. package/dist/callbacks/subscriptions/postGridEntityUpdate.lua +3 -3
  56. package/dist/callbacks/subscriptions/postItemPickup.d.ts +3 -3
  57. package/dist/callbacks/subscriptions/postItemPickup.lua +3 -3
  58. package/dist/callbacks/subscriptions/postKnifeInitLate.d.ts +3 -3
  59. package/dist/callbacks/subscriptions/postKnifeInitLate.lua +3 -3
  60. package/dist/callbacks/subscriptions/postLaserInitLate.d.ts +3 -3
  61. package/dist/callbacks/subscriptions/postLaserInitLate.lua +3 -3
  62. package/dist/callbacks/subscriptions/postNPCInitLate.d.ts +3 -3
  63. package/dist/callbacks/subscriptions/postNPCInitLate.lua +3 -3
  64. package/dist/callbacks/subscriptions/postNewLevelReordered.d.ts +3 -3
  65. package/dist/callbacks/subscriptions/postNewLevelReordered.lua +3 -3
  66. package/dist/callbacks/subscriptions/postNewRoomEarly.d.ts +4 -0
  67. package/dist/callbacks/subscriptions/postNewRoomEarly.lua +18 -0
  68. package/dist/callbacks/subscriptions/postNewRoomReordered.d.ts +3 -3
  69. package/dist/callbacks/subscriptions/postNewRoomReordered.lua +3 -3
  70. package/dist/callbacks/subscriptions/postPickupCollect.d.ts +3 -3
  71. package/dist/callbacks/subscriptions/postPickupCollect.lua +3 -3
  72. package/dist/callbacks/subscriptions/postPickupInitLate.d.ts +3 -3
  73. package/dist/callbacks/subscriptions/postPickupInitLate.lua +3 -3
  74. package/dist/callbacks/subscriptions/postPlayerChangeHealth.d.ts +3 -3
  75. package/dist/callbacks/subscriptions/postPlayerChangeHealth.lua +3 -3
  76. package/dist/callbacks/subscriptions/postPlayerChangeType.d.ts +3 -3
  77. package/dist/callbacks/subscriptions/postPlayerChangeType.lua +3 -3
  78. package/dist/callbacks/subscriptions/postPlayerFatalDamage.d.ts +3 -3
  79. package/dist/callbacks/subscriptions/postPlayerFatalDamage.lua +3 -3
  80. package/dist/callbacks/subscriptions/postPlayerInitLate.d.ts +3 -3
  81. package/dist/callbacks/subscriptions/postPlayerInitLate.lua +3 -3
  82. package/dist/callbacks/subscriptions/postPlayerInitReordered.d.ts +3 -3
  83. package/dist/callbacks/subscriptions/postPlayerInitReordered.lua +3 -3
  84. package/dist/callbacks/subscriptions/postPlayerRenderReordered.d.ts +3 -3
  85. package/dist/callbacks/subscriptions/postPlayerRenderReordered.lua +3 -3
  86. package/dist/callbacks/subscriptions/postPlayerUpdateReordered.d.ts +3 -3
  87. package/dist/callbacks/subscriptions/postPlayerUpdateReordered.lua +3 -3
  88. package/dist/callbacks/subscriptions/postProjectileInitLate.d.ts +3 -3
  89. package/dist/callbacks/subscriptions/postProjectileInitLate.lua +3 -3
  90. package/dist/callbacks/subscriptions/postPurchase.d.ts +3 -3
  91. package/dist/callbacks/subscriptions/postPurchase.lua +3 -3
  92. package/dist/callbacks/subscriptions/postSacrifice.d.ts +3 -3
  93. package/dist/callbacks/subscriptions/postSacrifice.lua +3 -3
  94. package/dist/callbacks/subscriptions/postSlotDestroyed.d.ts +3 -3
  95. package/dist/callbacks/subscriptions/postSlotDestroyed.lua +3 -3
  96. package/dist/callbacks/subscriptions/postSlotInit.d.ts +3 -3
  97. package/dist/callbacks/subscriptions/postSlotInit.lua +3 -3
  98. package/dist/callbacks/subscriptions/postSlotRender.d.ts +3 -3
  99. package/dist/callbacks/subscriptions/postSlotRender.lua +3 -3
  100. package/dist/callbacks/subscriptions/postSlotUpdate.d.ts +3 -3
  101. package/dist/callbacks/subscriptions/postSlotUpdate.lua +3 -3
  102. package/dist/callbacks/subscriptions/postTearInitLate.d.ts +3 -3
  103. package/dist/callbacks/subscriptions/postTearInitLate.lua +3 -3
  104. package/dist/callbacks/subscriptions/postTransformation.d.ts +3 -3
  105. package/dist/callbacks/subscriptions/postTransformation.lua +3 -3
  106. package/dist/callbacks/subscriptions/preCustomRevive.d.ts +3 -3
  107. package/dist/callbacks/subscriptions/preCustomRevive.lua +3 -3
  108. package/dist/callbacks/subscriptions/preItemPickup.d.ts +3 -3
  109. package/dist/callbacks/subscriptions/preItemPickup.lua +3 -3
  110. package/dist/constants.d.ts +18 -8
  111. package/dist/constants.lua +10 -8
  112. package/dist/features/deployJSONRoom.lua +16 -16
  113. package/dist/features/getCollectibleItemPoolType.lua +6 -28
  114. package/dist/features/saveDataManager/main.lua +5 -3
  115. package/dist/functions/collectibles.d.ts +23 -4
  116. package/dist/functions/collectibles.lua +22 -4
  117. package/dist/functions/flag.d.ts +1 -1
  118. package/dist/functions/gridEntity.d.ts +10 -5
  119. package/dist/functions/gridEntity.lua +19 -1
  120. package/dist/functions/input.d.ts +3 -5
  121. package/dist/functions/player.d.ts +5 -5
  122. package/dist/functions/revive.d.ts +2 -2
  123. package/dist/functions/rooms.d.ts +40 -20
  124. package/dist/functions/rooms.lua +63 -52
  125. package/dist/functions/sprite.d.ts +11 -0
  126. package/dist/functions/sprite.lua +9 -0
  127. package/dist/functions/util.d.ts +2 -2
  128. package/dist/functions/util.lua +2 -2
  129. package/dist/index.d.ts +1 -1
  130. package/dist/index.lua +1 -1
  131. package/dist/maps/roomShapeToTopLeftWallGridIndexMap.d.ts +3 -0
  132. package/dist/maps/roomShapeToTopLeftWallGridIndexMap.lua +12 -0
  133. package/dist/types/CallbackParametersCustom.d.ts +4 -0
  134. package/dist/types/ModCallbacksCustom.d.ts +34 -33
  135. package/dist/types/ModCallbacksCustom.lua +35 -33
  136. package/dist/types/ModUpgraded.lua +256 -243
  137. package/dist/upgradeMod.d.ts +2 -2
  138. package/dist/upgradeMod.lua +9 -6
  139. package/package.json +2 -2
@@ -1,8 +1,9 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
- local COLLECTIBLE_SPRITE_LAYER
4
+ local COLLECTIBLE_SPRITE_LAYER, COLLECTIBLE_SHADOW_LAYER
5
5
  local ____constants = require("constants")
6
+ local BLIND_ITEM_PNG_PATH = ____constants.BLIND_ITEM_PNG_PATH
6
7
  local SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = ____constants.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES
7
8
  local ____collectibleDescriptionMap = require("maps.collectibleDescriptionMap")
8
9
  local COLLECTIBLE_DESCRIPTION_MAP = ____collectibleDescriptionMap.COLLECTIBLE_DESCRIPTION_MAP
@@ -10,16 +11,22 @@ local ____collectibleNameMap = require("maps.collectibleNameMap")
10
11
  local COLLECTIBLE_NAME_MAP = ____collectibleNameMap.COLLECTIBLE_NAME_MAP
11
12
  local ____entity = require("functions.entity")
12
13
  local removeAllPickups = ____entity.removeAllPickups
14
+ local ____sprite = require("functions.sprite")
15
+ local clearSprite = ____sprite.clearSprite
13
16
  function ____exports.setCollectibleSprite(self, collectible, pngPath)
14
17
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
15
18
  error("You cannot set a collectible sprite for pickups of variant: " .. tostring(collectible.Variant))
16
19
  end
17
20
  local sprite = collectible:GetSprite()
18
- sprite:ReplaceSpritesheet(COLLECTIBLE_SPRITE_LAYER, pngPath)
19
- sprite:LoadGraphics()
21
+ if pngPath == nil then
22
+ clearSprite(nil, sprite, COLLECTIBLE_SPRITE_LAYER, COLLECTIBLE_SHADOW_LAYER)
23
+ else
24
+ sprite:ReplaceSpritesheet(COLLECTIBLE_SPRITE_LAYER, pngPath)
25
+ sprite:LoadGraphics()
26
+ end
20
27
  end
21
28
  COLLECTIBLE_SPRITE_LAYER = 1
22
- local BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png"
29
+ COLLECTIBLE_SHADOW_LAYER = 4
23
30
  local GLITCHED_ITEM_THRESHOLD = 4000000000
24
31
  function ____exports.collectibleHasTag(self, collectibleType, tag)
25
32
  local itemConfig = Isaac.GetItemConfig()
@@ -160,10 +167,21 @@ function ____exports.setCollectibleBlind(self, collectible)
160
167
  end
161
168
  ____exports.setCollectibleSprite(nil, collectible, BLIND_ITEM_PNG_PATH)
162
169
  end
170
+ function ____exports.setCollectibleEmpty(self, collectible)
171
+ if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
172
+ error("You cannot set a collectible to be empty for pickups of variant: " .. tostring(collectible.Variant))
173
+ end
174
+ collectible.SubType = CollectibleType.COLLECTIBLE_NULL
175
+ ____exports.setCollectibleSprite(nil, collectible)
176
+ end
163
177
  function ____exports.setCollectibleSubType(self, collectible, newCollectibleType)
164
178
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
165
179
  error("You cannot set a collectible sub type for pickups of variant: " .. tostring(collectible.Variant))
166
180
  end
181
+ if newCollectibleType == CollectibleType.COLLECTIBLE_NULL then
182
+ ____exports.setCollectibleEmpty(nil, collectible)
183
+ return
184
+ end
167
185
  collectible:Morph(
168
186
  EntityType.ENTITY_PICKUP,
169
187
  PickupVariant.PICKUP_COLLECTIBLE,
@@ -23,7 +23,7 @@
23
23
  */
24
24
  export declare function addFlag(flags: int, ...flag: int[]): int;
25
25
  /**
26
- * Helper function to check to see if a particular bit flag is set to true.
26
+ * Helper function to determine if a particular bit flag is set to true.
27
27
  * This is a variadic function, so pass as many flags as you want to check for.
28
28
  * If passed multiple flags, it will only return true if all of the flags are set.
29
29
  *
@@ -26,10 +26,16 @@ export declare function convertXMLGridEntityType(gridEntityXMLType: int, gridEnt
26
26
  * ```
27
27
  */
28
28
  export declare function getGridEntities(...gridEntityTypes: GridEntityType[]): GridEntity[];
29
+ export declare function getTopLeftWall(): GridEntity | undefined;
30
+ /**
31
+ * Helper function to get the grid index of the top left wall.
32
+ * (This will depend on what the current room shape is.)
33
+ */
34
+ export declare function getTopLeftWallGridIndex(): int;
29
35
  export declare function getSurroundingGridEntities(gridEntity: GridEntity): GridEntity[];
30
36
  /**
31
- * Helper function to see if all of the pressure plates in the current room are pushed. Returns true
32
- * if there are no pressure plates in the room.
37
+ * Helper function to determine if all of the pressure plates in the current room are pushed.
38
+ * Returns true if there are no pressure plates in the room.
33
39
  */
34
40
  export declare function isAllPressurePlatesPushed(): boolean;
35
41
  /**
@@ -78,10 +84,9 @@ export declare function removeAllMatchingGridEntities(...gridEntityType: GridEnt
78
84
  export declare function removeGridEntity(gridEntity: GridEntity, updateRoom?: boolean): void;
79
85
  /**
80
86
  * Helper function to make a grid entity invisible. This is accomplished by setting its sprite to
81
- * "gfx/none.png" (a non-existent PNG file).
87
+ * an empty/missing PNG file.
82
88
  *
83
- * Using this function will cause spurious errors in the "log.txt file". If you want to remove them,
84
- * create a transparent 1 pixel PNG file in your resources folder at "gfx/none.png".
89
+ * For more information, see the documentation for the "EMPTY_PNG_FILENAME" constant.
85
90
  */
86
91
  export declare function setGridEntityInvisible(gridEntity: GridEntity): void;
87
92
  export declare function spawnGiantPoop(topLeftGridIndex: int): void;
@@ -1,10 +1,22 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
+ local ____constants = require("constants")
5
+ local EMPTY_PNG_PATH = ____constants.EMPTY_PNG_PATH
4
6
  local ____gridEntityXMLMap = require("maps.gridEntityXMLMap")
5
7
  local GRID_ENTITY_XML_MAP = ____gridEntityXMLMap.GRID_ENTITY_XML_MAP
8
+ local ____roomShapeToTopLeftWallGridIndexMap = require("maps.roomShapeToTopLeftWallGridIndexMap")
9
+ local DEFAULT_TOP_LEFT_WALL_GRID_INDEX = ____roomShapeToTopLeftWallGridIndexMap.DEFAULT_TOP_LEFT_WALL_GRID_INDEX
10
+ local ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP = ____roomShapeToTopLeftWallGridIndexMap.ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP
6
11
  local ____rooms = require("functions.rooms")
7
12
  local roomUpdateSafe = ____rooms.roomUpdateSafe
13
+ function ____exports.getTopLeftWallGridIndex(self)
14
+ local game = Game()
15
+ local room = game:GetRoom()
16
+ local roomShape = room:GetRoomShape()
17
+ local topLeftWallGridIndex = ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP:get(roomShape)
18
+ return topLeftWallGridIndex == nil and DEFAULT_TOP_LEFT_WALL_GRID_INDEX or topLeftWallGridIndex
19
+ end
8
20
  function ____exports.removeGridEntity(self, gridEntity, updateRoom)
9
21
  if updateRoom == nil then
10
22
  updateRoom = true
@@ -75,6 +87,12 @@ function ____exports.getGridEntities(self, ...)
75
87
  end
76
88
  return gridEntities
77
89
  end
90
+ function ____exports.getTopLeftWall(self)
91
+ local game = Game()
92
+ local room = game:GetRoom()
93
+ local topLeftWallGridIndex = ____exports.getTopLeftWallGridIndex(nil)
94
+ return room:GetGridEntity(topLeftWallGridIndex)
95
+ end
78
96
  function ____exports.getSurroundingGridEntities(self, gridEntity)
79
97
  local game = Game()
80
98
  local room = game:GetRoom()
@@ -139,7 +157,7 @@ function ____exports.removeAllMatchingGridEntities(self, ...)
139
157
  end
140
158
  function ____exports.setGridEntityInvisible(self, gridEntity)
141
159
  local sprite = gridEntity:GetSprite()
142
- sprite:ReplaceSpritesheet(0, "gfx/none.png")
160
+ sprite:ReplaceSpritesheet(0, EMPTY_PNG_PATH)
143
161
  sprite:LoadGraphics()
144
162
  end
145
163
  function ____exports.spawnGiantPoop(self, topLeftGridIndex)
@@ -1,13 +1,11 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /** Helper function to get the enum name for the specified `Controller` value. */
3
3
  export declare function controllerToString(controller: Controller): string;
4
- /**
5
- * Iterates over all 4 inputs to see if a particular button is pressed (i.e. held down).
6
- */
4
+ /** Iterates over all 4 inputs to determine if a particular button is pressed (i.e. held down). */
7
5
  export declare function isActionPressedOnAnyInput(buttonAction: ButtonAction): boolean;
8
6
  /**
9
- * Iterates over all 4 inputs to see if a particular button is triggered
10
- * (i.e. held down and then released).
7
+ * Iterates over all 4 inputs to determine if a particular button is triggered (i.e. held down and
8
+ * then released).
11
9
  */
12
10
  export declare function isActionTriggeredOnAnyInput(buttonAction: ButtonAction): boolean;
13
11
  export declare function isKeyboardPressed(key: Keyboard): boolean;
@@ -21,14 +21,14 @@ export declare function anyPlayerHasCollectible(collectibleType: CollectibleType
21
21
  export declare function anyPlayerHasTrinket(trinketType: TrinketType | int): boolean;
22
22
  export declare function anyPlayerIs(matchingCharacter: PlayerType): boolean;
23
23
  /**
24
- * Helper function to see if the provided character can have red heart containers. Returns true for
25
- * characters like Isaac, Magdalene, or Cain. Returns true for Keeper and Tainted Keeper, even
26
- * though coin containers are not technically the same as red heart containers. Returns false for
27
- * characters like Blue Baby. Returns false for The Lost and Tainted Lost.
24
+ * Helper function to determine if the provided character can have red heart containers. Returns
25
+ * true for characters like Isaac, Magdalene, or Cain. Returns true for Keeper and Tainted Keeper,
26
+ * even though coin containers are not technically the same as red heart containers. Returns false
27
+ * for characters like Blue Baby. Returns false for The Lost and Tainted Lost.
28
28
  */
29
29
  export declare function characterCanHaveRedHearts(character: PlayerType): boolean;
30
30
  /**
31
- * Helper function to see if the provided character can have soul hearts. Returns true for
31
+ * Helper function to determine if the provided character can have soul hearts. Returns true for
32
32
  * characters like Isaac, Magdalene, or Cain. Returns false for characters like Bethany. Returns
33
33
  * false for The Lost and Tainted Lost.
34
34
  */
@@ -14,7 +14,7 @@ export declare function willPlayerRevive(player: EntityPlayer): boolean;
14
14
  */
15
15
  export declare function willMysteriousPaperRevive(player: EntityPlayer): boolean;
16
16
  /**
17
- * Helper function to see if the Spirit Shackles item is in an enabled state.
18
- * (It can be either enabled or disabled.)
17
+ * Helper function to determine if the Spirit Shackles item is in an enabled state. (It can be
18
+ * either enabled or disabled.)
19
19
  */
20
20
  export declare function willReviveFromSpiritShackles(player: EntityPlayer): boolean;
@@ -4,13 +4,7 @@
4
4
  * Always use this helper function over invoking `Game().ChangeRoom()` directly to ensure that you
5
5
  * do not forget to set the LeaveDoor property.
6
6
  */
7
- export declare function changeRoom(roomIndex: int): void;
8
- /**
9
- * This function will not work properly for the Death Certificate dimension. When in the Death
10
- * Certificate dimension, this function will randomly return either `Dimension.SECONDARY` or
11
- * `Dimension.DEATH_CERTIFICATE`. Use the `inDeathCertificateArea` function instead for that
12
- * purpose.
13
- */
7
+ export declare function changeRoom(roomGridIndex: int): void;
14
8
  export declare function getCurrentDimension(): Dimension;
15
9
  export declare function getRoomData(): RoomConfig | undefined;
16
10
  /**
@@ -23,23 +17,38 @@ export declare function getRoomData(): RoomConfig | undefined;
23
17
  */
24
18
  export declare function getRoomDataType(): int;
25
19
  /**
26
- * Helper function to get the room index of the current room. Use this instead of calling
27
- * `Level.GetCurrentRoomIndex()` directly to avoid bugs with big rooms. (Big rooms will return the
28
- * specific 1x1 quadrant that the player entered the room at, which can break data structures that
29
- * use the room index as an index.)
20
+ * Helper function to get the list grid index of the current room, which is equal to the index in
21
+ * the `Level.GetRooms().Get()` method. In other words, this is equal to the order that the room was
22
+ * created by the floor generation algorithm.
23
+ *
24
+ * Use this as an index for data structures that store data per room, since it is unique across
25
+ * different dimensions.
30
26
  */
31
- export declare function getRoomIndex(): int;
27
+ export declare function getRoomListIndex(): int;
28
+ /**
29
+ * Helper function to get the safe grid index of the current room. The safe grid index is defined as
30
+ * the top-left 1x1 section that the room overlaps with (or the top-right 1x1 section of a
31
+ * `RoomType.ROOMSHAPE_LTL` room).
32
+ *
33
+ * In most situations, using the safe grid index is more reliable than using the `GridIndex` or the
34
+ * `Level.GetCurrentRoomIndex()` method directly. `GridIndex` can return quadrants that are not on
35
+ * the map, and `Level.GetCurrentRoomIndex()` returns the specific 1x1 quadrant that the player
36
+ * entered the room at.
37
+ *
38
+ * Data structures that store data per room should use the room's `ListIndex` instead of
39
+ * `SafeGridIndex`, since the former is unique across different dimensions.
40
+ */
41
+ export declare function getRoomSafeGridIndex(): int;
32
42
  /**
33
43
  * Helper function to get an array of all of the safe grid indexes for rooms that match the
34
44
  * specified room type.
35
45
  *
36
46
  * This function only searches through rooms in the current dimension.
37
47
  */
38
- export declare function getRoomIndexesForType(roomType: RoomType): Set<int>;
48
+ export declare function getRoomGridIndexesForType(roomType: RoomType): Set<int>;
39
49
  /**
40
50
  * Helper function to get the item pool type for the current room. For example, this returns
41
- * `ItemPoolType.ItemPoolType.POOL_ANGEL` if you are in an Angel Room. Returns
42
- * `DEFAULT_ITEM_POOL_TYPE` if there is no particular pool associated with the current room type.
51
+ * `ItemPoolType.ItemPoolType.POOL_ANGEL` if you are in an Angel Room.
43
52
  */
44
53
  export declare function getRoomItemPoolType(): ItemPoolType;
45
54
  /**
@@ -73,6 +82,11 @@ export declare function getRoomSubType(): int;
73
82
  * @returns The room variant. Returns -1 if the variant was not found.
74
83
  */
75
84
  export declare function getRoomVariant(): int;
85
+ /**
86
+ * The room visited count will be inaccurate during the period before the PostNewRoom callback has
87
+ * fired (i.e. when entities are initializing and performing their first update). This is because
88
+ * the variable is only incremented immediately before the PostNewRoom callback fires.
89
+ */
76
90
  export declare function getRoomVisitedCount(): int;
77
91
  /**
78
92
  * Converts a room X and Y coordinate to a position. For example, the coordinates of 0, 0 are
@@ -80,7 +94,7 @@ export declare function getRoomVisitedCount(): int;
80
94
  */
81
95
  export declare function gridToPos(x: int, y: int): Vector;
82
96
  /**
83
- * Helper function to see if the current room shape is equal to `RoomShape.ROOMSHAPE_1x2` or
97
+ * Helper function to determine if the current room shape is equal to `RoomShape.ROOMSHAPE_1x2` or
84
98
  * `RoomShape.ROOMSHAPE_2x1`.
85
99
  */
86
100
  export declare function in2x1Room(): boolean;
@@ -98,16 +112,22 @@ export declare function inBossRoomOf(bossID: BossID): boolean;
98
112
  */
99
113
  export declare function inCrawlspace(): boolean;
100
114
  /**
101
- * We cannot use the `inDimension` function for this since it is bugged with the Death Certificate
102
- * area.
115
+ * We cannot use the standard code in the `inDimension` function for this purpose since it is bugged
116
+ * with the Death Certificate area.
103
117
  */
104
118
  export declare function inDeathCertificateArea(): boolean;
105
- export declare function isDevilsCrownTreasureRoom(): boolean;
119
+ export declare function inDevilsCrownTreasureRoom(): boolean;
106
120
  export declare function inDimension(dimension: Dimension): boolean;
107
- /** Helper function to see if the current room shape is one of the four L room shapes. */
121
+ /** Helper function to determine if the current room shape is one of the four L room shapes. */
108
122
  export declare function inLRoom(): boolean;
109
123
  export declare function inGenesisRoom(): boolean;
124
+ /** Helper function to determine whether or not the current room is the starting room of a floor. */
110
125
  export declare function inStartingRoom(): boolean;
126
+ /**
127
+ * Helper function to determine whether or not the current room is part of the floor layout. For
128
+ * example, Devil Rooms and the Mega Satan room are not considered to be inside the map.
129
+ */
130
+ export declare function isRoomInsideMap(): boolean;
111
131
  /**
112
132
  * If `Room.Update()` is called in a PostNewRoom callback, then some entities will slide around
113
133
  * (such as the player). Since those entity velocities are already at zero, setting them to zero
@@ -2,12 +2,9 @@
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
4
  local ____constants = require("constants")
5
- local DEFAULT_ITEM_POOL_TYPE = ____constants.DEFAULT_ITEM_POOL_TYPE
6
5
  local GENESIS_ROOM_SUBTYPE = ____constants.GENESIS_ROOM_SUBTYPE
7
6
  local GENESIS_ROOM_VARIANT = ____constants.GENESIS_ROOM_VARIANT
8
7
  local MAX_ROOM_INDEX = ____constants.MAX_ROOM_INDEX
9
- local ____roomTypeToItemPoolMap = require("maps.roomTypeToItemPoolMap")
10
- local ROOM_TYPE_TO_ITEM_POOL_TYPE_MAP = ____roomTypeToItemPoolMap.ROOM_TYPE_TO_ITEM_POOL_TYPE_MAP
11
8
  local ____doors = require("functions.doors")
12
9
  local closeAllDoors = ____doors.closeAllDoors
13
10
  local getDoors = ____doors.getDoors
@@ -20,28 +17,57 @@ local setEntityPositions = ____entity.setEntityPositions
20
17
  local setEntityVelocities = ____entity.setEntityVelocities
21
18
  local ____flag = require("functions.flag")
22
19
  local hasFlag = ____flag.hasFlag
23
- function ____exports.getRoomIndex(self)
20
+ function ____exports.getRoomData(self)
21
+ local game = Game()
22
+ local level = game:GetLevel()
23
+ local roomSafeGridIndex = ____exports.getRoomSafeGridIndex(nil)
24
+ local roomDesc = level:GetRoomByIdx(roomSafeGridIndex)
25
+ return roomDesc.Data
26
+ end
27
+ function ____exports.getRoomSafeGridIndex(self)
24
28
  local game = Game()
25
29
  local level = game:GetLevel()
26
30
  local roomDesc = level:GetCurrentRoomDesc()
27
31
  return roomDesc.SafeGridIndex
28
32
  end
29
- function ____exports.changeRoom(self, roomIndex)
33
+ function ____exports.getRoomStageID(self)
34
+ local roomData = ____exports.getRoomData(nil)
35
+ if roomData == nil then
36
+ return -1
37
+ end
38
+ return roomData.StageID
39
+ end
40
+ function ____exports.getRoomSubType(self)
41
+ local roomData = ____exports.getRoomData(nil)
42
+ if roomData == nil then
43
+ return -1
44
+ end
45
+ return roomData.Subtype
46
+ end
47
+ function ____exports.inDeathCertificateArea(self)
48
+ local roomStageID = ____exports.getRoomStageID(nil)
49
+ local roomSubType = ____exports.getRoomSubType(nil)
50
+ return roomStageID == 35 and (roomSubType == 33 or roomSubType == 33)
51
+ end
52
+ function ____exports.changeRoom(self, roomGridIndex)
30
53
  local game = Game()
31
54
  local level = game:GetLevel()
32
55
  level.LeaveDoor = -1
33
- game:ChangeRoom(roomIndex)
56
+ game:ChangeRoom(roomGridIndex)
34
57
  end
35
58
  function ____exports.getCurrentDimension(self)
36
59
  local game = Game()
37
60
  local level = game:GetLevel()
38
- local startingRoomIndex = level:GetStartingRoomIndex()
39
- local startingRoomDesc = level:GetRoomByIdx(startingRoomIndex, -1)
61
+ if ____exports.inDeathCertificateArea(nil) then
62
+ return 2
63
+ end
64
+ local startingRoomGridIndex = level:GetStartingRoomIndex()
65
+ local startingRoomDesc = level:GetRoomByIdx(startingRoomGridIndex, -1)
40
66
  local startingRoomHash = GetPtrHash(startingRoomDesc)
41
67
  do
42
68
  local dimension = 0
43
69
  while dimension <= 2 do
44
- local dimensionRoomDesc = level:GetRoomByIdx(startingRoomIndex, dimension)
70
+ local dimensionRoomDesc = level:GetRoomByIdx(startingRoomGridIndex, dimension)
45
71
  local dimensionRoomHash = GetPtrHash(dimensionRoomDesc)
46
72
  if dimensionRoomHash == startingRoomHash then
47
73
  return dimension
@@ -49,16 +75,9 @@ function ____exports.getCurrentDimension(self)
49
75
  dimension = dimension + 1
50
76
  end
51
77
  end
52
- error("Failed to get the current dimension using the starting room index of: " .. tostring(startingRoomIndex))
78
+ error("Failed to get the current dimension using the starting room index of: " .. tostring(startingRoomGridIndex))
53
79
  return 0
54
80
  end
55
- function ____exports.getRoomData(self)
56
- local game = Game()
57
- local level = game:GetLevel()
58
- local roomIndex = ____exports.getRoomIndex(nil)
59
- local roomDesc = level:GetRoomByIdx(roomIndex)
60
- return roomDesc.Data
61
- end
62
81
  function ____exports.getRoomDataType(self)
63
82
  local roomData = ____exports.getRoomData(nil)
64
83
  if roomData == nil then
@@ -66,28 +85,35 @@ function ____exports.getRoomDataType(self)
66
85
  end
67
86
  return roomData.Type
68
87
  end
69
- function ____exports.getRoomIndexesForType(self, roomType)
88
+ function ____exports.getRoomListIndex(self)
89
+ local game = Game()
90
+ local level = game:GetLevel()
91
+ local roomDesc = level:GetCurrentRoomDesc()
92
+ return roomDesc.ListIndex
93
+ end
94
+ function ____exports.getRoomGridIndexesForType(self, roomType)
70
95
  local game = Game()
71
96
  local level = game:GetLevel()
72
- local roomIndexes = __TS__New(Set)
97
+ local roomGridIndexes = __TS__New(Set)
73
98
  do
74
99
  local i = 0
75
100
  while i <= MAX_ROOM_INDEX do
76
101
  local room = level:GetRoomByIdx(i)
77
102
  if room ~= nil and room.Data ~= nil and room.Data.Type == roomType then
78
- roomIndexes:add(room.SafeGridIndex)
103
+ roomGridIndexes:add(room.SafeGridIndex)
79
104
  end
80
105
  i = i + 1
81
106
  end
82
107
  end
83
- return roomIndexes
108
+ return roomGridIndexes
84
109
  end
85
110
  function ____exports.getRoomItemPoolType(self)
86
111
  local game = Game()
112
+ local itemPool = game:GetItemPool()
87
113
  local room = game:GetRoom()
88
114
  local roomType = room:GetType()
89
- local itemPoolType = ROOM_TYPE_TO_ITEM_POOL_TYPE_MAP:get(roomType)
90
- return itemPoolType == nil and DEFAULT_ITEM_POOL_TYPE or itemPoolType
115
+ local roomSeed = room:GetSpawnSeed()
116
+ return itemPool:GetPoolForRoom(roomType, roomSeed)
91
117
  end
92
118
  function ____exports.getRoomName(self)
93
119
  local roomData = ____exports.getRoomData(nil)
@@ -96,20 +122,6 @@ function ____exports.getRoomName(self)
96
122
  end
97
123
  return roomData.Name
98
124
  end
99
- function ____exports.getRoomStageID(self)
100
- local roomData = ____exports.getRoomData(nil)
101
- if roomData == nil then
102
- return -1
103
- end
104
- return roomData.StageID
105
- end
106
- function ____exports.getRoomSubType(self)
107
- local roomData = ____exports.getRoomData(nil)
108
- if roomData == nil then
109
- return -1
110
- end
111
- return roomData.Subtype
112
- end
113
125
  function ____exports.getRoomVariant(self)
114
126
  local roomData = ____exports.getRoomData(nil)
115
127
  if roomData == nil then
@@ -145,9 +157,9 @@ function ____exports.inAngelShop(self)
145
157
  return roomType == RoomType.ROOM_ANGEL and roomSubType == 1
146
158
  end
147
159
  function ____exports.inBeastRoom(self)
148
- local roomIndex = ____exports.getRoomIndex(nil)
160
+ local roomSafeGridIndex = ____exports.getRoomSafeGridIndex(nil)
149
161
  local roomSubType = ____exports.getRoomSubType(nil)
150
- return roomIndex == GridRooms.ROOM_DUNGEON_IDX and roomSubType == 4
162
+ return roomSafeGridIndex == GridRooms.ROOM_DUNGEON_IDX and roomSubType == 4
151
163
  end
152
164
  function ____exports.inBossRoomOf(self, bossID)
153
165
  local game = Game()
@@ -158,16 +170,11 @@ function ____exports.inBossRoomOf(self, bossID)
158
170
  return roomType == RoomType.ROOM_BOSS and roomStageID == 0 and roomSubType == bossID
159
171
  end
160
172
  function ____exports.inCrawlspace(self)
161
- local roomIndex = ____exports.getRoomIndex(nil)
173
+ local roomSafeGridIndex = ____exports.getRoomSafeGridIndex(nil)
162
174
  local roomSubType = ____exports.getRoomSubType(nil)
163
- return roomIndex == GridRooms.ROOM_DUNGEON_IDX and roomSubType ~= 4
175
+ return roomSafeGridIndex == GridRooms.ROOM_DUNGEON_IDX and roomSubType ~= 4
164
176
  end
165
- function ____exports.inDeathCertificateArea(self)
166
- local roomStageID = ____exports.getRoomStageID(nil)
167
- local roomSubType = ____exports.getRoomSubType(nil)
168
- return roomStageID == 35 and (roomSubType == 33 or roomSubType == 33)
169
- end
170
- function ____exports.isDevilsCrownTreasureRoom(self)
177
+ function ____exports.inDevilsCrownTreasureRoom(self)
171
178
  local game = Game()
172
179
  local level = game:GetLevel()
173
180
  local roomDesc = level:GetCurrentRoomDesc()
@@ -193,9 +200,13 @@ end
193
200
  function ____exports.inStartingRoom(self)
194
201
  local game = Game()
195
202
  local level = game:GetLevel()
196
- local startingRoomIndex = level:GetStartingRoomIndex()
197
- local roomIndex = ____exports.getRoomIndex(nil)
198
- return roomIndex == startingRoomIndex
203
+ local startingRoomGridIndex = level:GetStartingRoomIndex()
204
+ local roomSafeGridIndex = ____exports.getRoomSafeGridIndex(nil)
205
+ return roomSafeGridIndex == startingRoomGridIndex
206
+ end
207
+ function ____exports.isRoomInsideMap(self)
208
+ local roomSafeGridIndex = ____exports.getRoomSafeGridIndex(nil)
209
+ return roomSafeGridIndex >= 0
199
210
  end
200
211
  function ____exports.roomUpdateSafe(self)
201
212
  local game = Game()
@@ -219,14 +230,14 @@ function ____exports.setRoomCleared(self)
219
230
  for ____, door in ipairs(getDoors(nil)) do
220
231
  do
221
232
  if isHiddenSecretRoomDoor(nil, door) then
222
- goto __continue38
233
+ goto __continue41
223
234
  end
224
235
  door.State = DoorState.STATE_OPEN
225
236
  local sprite = door:GetSprite()
226
237
  sprite:Play("Opened", true)
227
238
  door.ExtraVisible = false
228
239
  end
229
- ::__continue38::
240
+ ::__continue41::
230
241
  end
231
242
  sfx:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
232
243
  game:ShakeScreen(0)
@@ -1,4 +1,15 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to clear a specific layer from a sprite. This function is variadic, so pass as
4
+ * many layer IDs as you want to clear.
5
+ *
6
+ * Since there is no official API method to "clear" a sprite, we can work around it by setting the
7
+ * spritesheet to a non-existent or completely transparent file. If the path to the spritesheet does
8
+ * not exist, then this function might cause spurious errors to appear in the "log.txt file". To
9
+ * silence these errors, create a transparent 1 pixel PNG file in your mod's resources folder at the
10
+ * path corresponding to the "EMPTY_PNG_PATH" constant.
11
+ */
12
+ export declare function clearSprite(sprite: Sprite, ...layerIDs: int[]): void;
2
13
  /**
3
14
  * Helper function that returns the number of the final frame in a particular animation for a
4
15
  * sprite. By default, it will use the currently playing animation, but you can also specify a
@@ -1,5 +1,14 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
+ local ____constants = require("constants")
4
+ local EMPTY_PNG_PATH = ____constants.EMPTY_PNG_PATH
5
+ function ____exports.clearSprite(self, sprite, ...)
6
+ local layerIDs = {...}
7
+ for ____, layerID in ipairs(layerIDs) do
8
+ sprite:ReplaceSpritesheet(layerID, EMPTY_PNG_PATH)
9
+ end
10
+ sprite:LoadGraphics()
11
+ end
3
12
  function ____exports.getFinalFrameOfAnimation(self, sprite, animation)
4
13
  local currentAnimation = sprite:GetAnimation()
5
14
  local currentFrame = sprite:GetFrame()
@@ -80,8 +80,8 @@ export declare function tableClear(table: LuaTable): void;
80
80
  * arguments. Use this function instead of invoking `Game.StartRoomTransition()` directly so that
81
81
  * you don't forget to set `Level.LeaveDoor` property.
82
82
  *
83
- * @param roomIndex The room index of the destination room.
83
+ * @param roomGridIndex The room grid index of the destination room.
84
84
  * @param direction Optional. Default is `Direction.NO_DIRECTION`.
85
85
  * @param roomTransitionAnim Optional. Default is `RoomTransitionAnim.TELEPORT`.
86
86
  */
87
- export declare function teleport(roomIndex: int, direction?: Direction, roomTransitionAnim?: RoomTransitionAnim): void;
87
+ export declare function teleport(roomGridIndex: int, direction?: Direction, roomTransitionAnim?: RoomTransitionAnim): void;
@@ -62,7 +62,7 @@ function ____exports.tableClear(self, ____table)
62
62
  ____table[key] = nil
63
63
  end
64
64
  end
65
- function ____exports.teleport(self, roomIndex, direction, roomTransitionAnim)
65
+ function ____exports.teleport(self, roomGridIndex, direction, roomTransitionAnim)
66
66
  if direction == nil then
67
67
  direction = Direction.NO_DIRECTION
68
68
  end
@@ -72,6 +72,6 @@ function ____exports.teleport(self, roomIndex, direction, roomTransitionAnim)
72
72
  local game = Game()
73
73
  local level = game:GetLevel()
74
74
  level.LeaveDoor = -1
75
- game:StartRoomTransition(roomIndex, direction, roomTransitionAnim)
75
+ game:StartRoomTransition(roomGridIndex, direction, roomTransitionAnim)
76
76
  end
77
77
  return ____exports
package/dist/index.d.ts CHANGED
@@ -52,7 +52,7 @@ export * from "./maps/cardNameMap";
52
52
  export * from "./maps/collectibleNameMap";
53
53
  export * from "./maps/gridEntityXMLMap";
54
54
  export * from "./maps/pillEffectNameMap";
55
- export * from "./maps/roomTypeToItemPoolMap";
55
+ export * from "./maps/roomShapeToTopLeftWallGridIndexMap";
56
56
  export * from "./maps/transformationMap";
57
57
  export * from "./maps/trinketNameMap";
58
58
  export * from "./sets/cards";
package/dist/index.lua CHANGED
@@ -423,7 +423,7 @@ do
423
423
  end
424
424
  end
425
425
  do
426
- local ____export = require("maps.roomTypeToItemPoolMap")
426
+ local ____export = require("maps.roomShapeToTopLeftWallGridIndexMap")
427
427
  for ____exportKey, ____exportValue in pairs(____export) do
428
428
  if ____exportKey ~= "default" then
429
429
  ____exports[____exportKey] = ____exportValue
@@ -0,0 +1,3 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export declare const ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP: Map<RoomShape, number>;
3
+ export declare const DEFAULT_TOP_LEFT_WALL_GRID_INDEX = 0;
@@ -0,0 +1,12 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ require("lualib_bundle");
3
+ local ____exports = {}
4
+ ____exports.ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP = __TS__New(Map, {
5
+ {RoomShape.ROOMSHAPE_IH, 30},
6
+ {RoomShape.ROOMSHAPE_IV, 4},
7
+ {RoomShape.ROOMSHAPE_IIV, 4},
8
+ {RoomShape.ROOMSHAPE_IIH, 56},
9
+ {RoomShape.ROOMSHAPE_LTL, 13}
10
+ })
11
+ ____exports.DEFAULT_TOP_LEFT_WALL_GRID_INDEX = 0
12
+ return ____exports
@@ -16,6 +16,7 @@ import { PostItemPickupCallbackType } from "../callbacks/subscriptions/postItemP
16
16
  import { PostKnifeInitLateCallbackType } from "../callbacks/subscriptions/postKnifeInitLate";
17
17
  import { PostLaserInitLateCallbackType } from "../callbacks/subscriptions/postLaserInitLate";
18
18
  import { PostNewLevelReorderedCallbackType } from "../callbacks/subscriptions/postNewLevelReordered";
19
+ import { PostNewRoomEarlyCallbackType } from "../callbacks/subscriptions/postNewRoomEarly";
19
20
  import { PostNewRoomReorderedCallbackType } from "../callbacks/subscriptions/postNewRoomReordered";
20
21
  import { PostNPCInitLateCallbackType } from "../callbacks/subscriptions/postNPCInitLate";
21
22
  import { PostPickupCollectCallbackType } from "../callbacks/subscriptions/postPickupCollect";
@@ -61,6 +62,9 @@ export interface CallbackParametersCustom {
61
62
  callback: PostPlayerRenderReorderedCallbackType,
62
63
  playerVariant?: PlayerVariant
63
64
  ];
65
+ [ModCallbacksCustom.MC_POST_NEW_ROOM_EARLY]: [
66
+ callback: PostNewRoomEarlyCallbackType
67
+ ];
64
68
  [ModCallbacksCustom.MC_POST_PLAYER_INIT_LATE]: [
65
69
  callback: PostPlayerInitLateCallbackType,
66
70
  playerVariant?: PlayerVariant