isaacscript-common 1.0.497 → 1.0.501

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 (146) hide show
  1. package/dist/callbacks/customRevive.lua +9 -5
  2. package/dist/callbacks/itemPickup.lua +9 -5
  3. package/dist/callbacks/postBombInitLate.d.ts +2 -2
  4. package/dist/callbacks/postBombInitLate.lua +16 -19
  5. package/dist/callbacks/postCursedTeleport.lua +5 -3
  6. package/dist/callbacks/postEffectInitLate.d.ts +2 -2
  7. package/dist/callbacks/postEffectInitLate.lua +16 -19
  8. package/dist/callbacks/postEsauJr.lua +9 -5
  9. package/dist/callbacks/postFamiliarInitLate.d.ts +2 -2
  10. package/dist/callbacks/postFamiliarInitLate.lua +16 -19
  11. package/dist/callbacks/postFlip.lua +9 -5
  12. package/dist/callbacks/postGridEntity.lua +13 -7
  13. package/dist/callbacks/postKnifeInitLate.d.ts +2 -2
  14. package/dist/callbacks/postKnifeInitLate.lua +16 -19
  15. package/dist/callbacks/postLaserInitLate.d.ts +2 -2
  16. package/dist/callbacks/postLaserInitLate.lua +16 -19
  17. package/dist/callbacks/postNPCInitLate.d.ts +2 -2
  18. package/dist/callbacks/postNPCInitLate.lua +16 -19
  19. package/dist/callbacks/postNewRoomEarly.d.ts +2 -0
  20. package/dist/callbacks/postNewRoomEarly.lua +46 -0
  21. package/dist/callbacks/postPickupCollect.lua +5 -3
  22. package/dist/callbacks/postPickupInitLate.d.ts +2 -2
  23. package/dist/callbacks/postPickupInitLate.lua +16 -19
  24. package/dist/callbacks/postPlayerChangeHealth.lua +5 -3
  25. package/dist/callbacks/postPlayerChangeType.lua +5 -3
  26. package/dist/callbacks/postPlayerFatalDamage.lua +5 -3
  27. package/dist/callbacks/postPlayerInitLate.lua +5 -3
  28. package/dist/callbacks/postPlayerReordered.lua +16 -10
  29. package/dist/callbacks/postProjectileInitLate.d.ts +2 -2
  30. package/dist/callbacks/postProjectileInitLate.lua +16 -19
  31. package/dist/callbacks/postPurchase.lua +11 -3
  32. package/dist/callbacks/postSacrifice.lua +5 -3
  33. package/dist/callbacks/postSlotInitUpdate.lua +9 -5
  34. package/dist/callbacks/postSlotRenderBroken.lua +9 -5
  35. package/dist/callbacks/postTearInitLate.d.ts +2 -2
  36. package/dist/callbacks/postTearInitLate.lua +16 -19
  37. package/dist/callbacks/postTransformation.lua +5 -3
  38. package/dist/callbacks/reorderedCallbacks.lua +18 -12
  39. package/dist/callbacks/subscriptions/postBombInitLate.d.ts +3 -3
  40. package/dist/callbacks/subscriptions/postBombInitLate.lua +3 -3
  41. package/dist/callbacks/subscriptions/postCursedTeleport.d.ts +3 -3
  42. package/dist/callbacks/subscriptions/postCursedTeleport.lua +3 -3
  43. package/dist/callbacks/subscriptions/postCustomRevive.d.ts +3 -3
  44. package/dist/callbacks/subscriptions/postCustomRevive.lua +3 -3
  45. package/dist/callbacks/subscriptions/postEffectInitLate.d.ts +3 -3
  46. package/dist/callbacks/subscriptions/postEffectInitLate.lua +3 -3
  47. package/dist/callbacks/subscriptions/postEsauJr.d.ts +3 -3
  48. package/dist/callbacks/subscriptions/postEsauJr.lua +3 -3
  49. package/dist/callbacks/subscriptions/postFamiliarInitLate.d.ts +3 -3
  50. package/dist/callbacks/subscriptions/postFamiliarInitLate.lua +3 -3
  51. package/dist/callbacks/subscriptions/postFirstEsauJr.d.ts +3 -3
  52. package/dist/callbacks/subscriptions/postFirstEsauJr.lua +3 -3
  53. package/dist/callbacks/subscriptions/postFirstFlip.d.ts +3 -3
  54. package/dist/callbacks/subscriptions/postFirstFlip.lua +3 -3
  55. package/dist/callbacks/subscriptions/postFlip.d.ts +3 -3
  56. package/dist/callbacks/subscriptions/postFlip.lua +3 -3
  57. package/dist/callbacks/subscriptions/postGameStartedReordered.d.ts +3 -3
  58. package/dist/callbacks/subscriptions/postGameStartedReordered.lua +3 -3
  59. package/dist/callbacks/subscriptions/postGridEntityInit.d.ts +3 -3
  60. package/dist/callbacks/subscriptions/postGridEntityInit.lua +3 -3
  61. package/dist/callbacks/subscriptions/postGridEntityRemove.d.ts +3 -3
  62. package/dist/callbacks/subscriptions/postGridEntityRemove.lua +3 -3
  63. package/dist/callbacks/subscriptions/postGridEntityUpdate.d.ts +3 -3
  64. package/dist/callbacks/subscriptions/postGridEntityUpdate.lua +3 -3
  65. package/dist/callbacks/subscriptions/postItemPickup.d.ts +3 -3
  66. package/dist/callbacks/subscriptions/postItemPickup.lua +3 -3
  67. package/dist/callbacks/subscriptions/postKnifeInitLate.d.ts +3 -3
  68. package/dist/callbacks/subscriptions/postKnifeInitLate.lua +3 -3
  69. package/dist/callbacks/subscriptions/postLaserInitLate.d.ts +3 -3
  70. package/dist/callbacks/subscriptions/postLaserInitLate.lua +3 -3
  71. package/dist/callbacks/subscriptions/postNPCInitLate.d.ts +3 -3
  72. package/dist/callbacks/subscriptions/postNPCInitLate.lua +3 -3
  73. package/dist/callbacks/subscriptions/postNewLevelReordered.d.ts +3 -3
  74. package/dist/callbacks/subscriptions/postNewLevelReordered.lua +3 -3
  75. package/dist/callbacks/subscriptions/postNewRoomEarly.d.ts +4 -0
  76. package/dist/callbacks/subscriptions/postNewRoomEarly.lua +18 -0
  77. package/dist/callbacks/subscriptions/postNewRoomReordered.d.ts +3 -3
  78. package/dist/callbacks/subscriptions/postNewRoomReordered.lua +3 -3
  79. package/dist/callbacks/subscriptions/postPickupCollect.d.ts +3 -3
  80. package/dist/callbacks/subscriptions/postPickupCollect.lua +3 -3
  81. package/dist/callbacks/subscriptions/postPickupInitLate.d.ts +3 -3
  82. package/dist/callbacks/subscriptions/postPickupInitLate.lua +3 -3
  83. package/dist/callbacks/subscriptions/postPlayerChangeHealth.d.ts +3 -3
  84. package/dist/callbacks/subscriptions/postPlayerChangeHealth.lua +3 -3
  85. package/dist/callbacks/subscriptions/postPlayerChangeType.d.ts +3 -3
  86. package/dist/callbacks/subscriptions/postPlayerChangeType.lua +3 -3
  87. package/dist/callbacks/subscriptions/postPlayerFatalDamage.d.ts +3 -3
  88. package/dist/callbacks/subscriptions/postPlayerFatalDamage.lua +3 -3
  89. package/dist/callbacks/subscriptions/postPlayerInitLate.d.ts +3 -3
  90. package/dist/callbacks/subscriptions/postPlayerInitLate.lua +3 -3
  91. package/dist/callbacks/subscriptions/postPlayerInitReordered.d.ts +3 -3
  92. package/dist/callbacks/subscriptions/postPlayerInitReordered.lua +3 -3
  93. package/dist/callbacks/subscriptions/postPlayerRenderReordered.d.ts +3 -3
  94. package/dist/callbacks/subscriptions/postPlayerRenderReordered.lua +3 -3
  95. package/dist/callbacks/subscriptions/postPlayerUpdateReordered.d.ts +3 -3
  96. package/dist/callbacks/subscriptions/postPlayerUpdateReordered.lua +3 -3
  97. package/dist/callbacks/subscriptions/postProjectileInitLate.d.ts +3 -3
  98. package/dist/callbacks/subscriptions/postProjectileInitLate.lua +3 -3
  99. package/dist/callbacks/subscriptions/postPurchase.d.ts +3 -3
  100. package/dist/callbacks/subscriptions/postPurchase.lua +3 -3
  101. package/dist/callbacks/subscriptions/postSacrifice.d.ts +3 -3
  102. package/dist/callbacks/subscriptions/postSacrifice.lua +3 -3
  103. package/dist/callbacks/subscriptions/postSlotDestroyed.d.ts +3 -3
  104. package/dist/callbacks/subscriptions/postSlotDestroyed.lua +3 -3
  105. package/dist/callbacks/subscriptions/postSlotInit.d.ts +3 -3
  106. package/dist/callbacks/subscriptions/postSlotInit.lua +3 -3
  107. package/dist/callbacks/subscriptions/postSlotRender.d.ts +3 -3
  108. package/dist/callbacks/subscriptions/postSlotRender.lua +3 -3
  109. package/dist/callbacks/subscriptions/postSlotUpdate.d.ts +3 -3
  110. package/dist/callbacks/subscriptions/postSlotUpdate.lua +3 -3
  111. package/dist/callbacks/subscriptions/postTearInitLate.d.ts +3 -3
  112. package/dist/callbacks/subscriptions/postTearInitLate.lua +3 -3
  113. package/dist/callbacks/subscriptions/postTransformation.d.ts +3 -3
  114. package/dist/callbacks/subscriptions/postTransformation.lua +3 -3
  115. package/dist/callbacks/subscriptions/preCustomRevive.d.ts +3 -3
  116. package/dist/callbacks/subscriptions/preCustomRevive.lua +3 -3
  117. package/dist/callbacks/subscriptions/preItemPickup.d.ts +3 -3
  118. package/dist/callbacks/subscriptions/preItemPickup.lua +3 -3
  119. package/dist/constants.d.ts +18 -8
  120. package/dist/constants.lua +10 -8
  121. package/dist/features/deployJSONRoom.lua +16 -16
  122. package/dist/features/getCollectibleItemPoolType.lua +6 -28
  123. package/dist/functions/collectibles.d.ts +26 -1
  124. package/dist/functions/collectibles.lua +27 -4
  125. package/dist/functions/flag.d.ts +1 -1
  126. package/dist/functions/gridEntity.d.ts +10 -5
  127. package/dist/functions/gridEntity.lua +19 -1
  128. package/dist/functions/input.d.ts +3 -5
  129. package/dist/functions/player.d.ts +5 -5
  130. package/dist/functions/revive.d.ts +2 -2
  131. package/dist/functions/rooms.d.ts +40 -20
  132. package/dist/functions/rooms.lua +63 -52
  133. package/dist/functions/sprite.d.ts +11 -0
  134. package/dist/functions/sprite.lua +9 -0
  135. package/dist/functions/util.d.ts +2 -2
  136. package/dist/functions/util.lua +2 -2
  137. package/dist/index.d.ts +1 -1
  138. package/dist/index.lua +1 -1
  139. package/dist/maps/roomShapeToTopLeftWallGridIndexMap.d.ts +3 -0
  140. package/dist/maps/roomShapeToTopLeftWallGridIndexMap.lua +12 -0
  141. package/dist/types/CallbackParametersCustom.d.ts +4 -0
  142. package/dist/types/ModCallbacksCustom.d.ts +34 -33
  143. package/dist/types/ModCallbacksCustom.lua +35 -33
  144. package/dist/types/ModUpgraded.lua +256 -243
  145. package/dist/upgradeMod.lua +3 -0
  146. package/package.json +2 -2
@@ -1,49 +1,27 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
- local postPickupInitCollectible, preGetCollectible, v
4
+ local postPickupInitCollectible, v
5
5
  local ____errors = require("errors")
6
6
  local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
7
- local ____array = require("functions.array")
8
- local arrayEmpty = ____array.arrayEmpty
9
7
  local ____rooms = require("functions.rooms")
10
- local getRoomIndex = ____rooms.getRoomIndex
11
8
  local getRoomItemPoolType = ____rooms.getRoomItemPoolType
12
- local getRoomVisitedCount = ____rooms.getRoomVisitedCount
13
9
  local ____exports = require("features.saveDataManager.exports")
14
10
  local saveDataManager = ____exports.saveDataManager
15
11
  function postPickupInitCollectible(self, pickup)
16
- local itemPoolType = __TS__ArrayShift(v.run.collectibleQueue)
17
- if itemPoolType == nil then
18
- return
19
- end
12
+ local game = Game()
13
+ local itemPool = game:GetItemPool()
20
14
  local ptrHash = GetPtrHash(pickup)
21
- v.run.collectibleItemPoolTypeMap:set(ptrHash, itemPoolType)
22
- end
23
- function preGetCollectible(self, itemPoolType, _decrease, _seed)
24
- local roomIndex = getRoomIndex(nil)
25
- local roomVisitedCount = getRoomVisitedCount(nil)
26
- if roomIndex ~= v.run.currentRoomIndex or roomVisitedCount ~= v.run.currentRoomVisitedCount then
27
- v.run.currentRoomIndex = roomIndex
28
- v.run.currentRoomVisitedCount = roomVisitedCount
29
- arrayEmpty(nil, v.run.collectibleQueue)
30
- v.run.collectibleItemPoolTypeMap:clear()
31
- end
32
- __TS__ArrayPush(v.run.collectibleQueue, itemPoolType)
15
+ local lastItemPoolType = itemPool:GetLastPool()
16
+ v.run.collectibleItemPoolTypeMap:set(ptrHash, lastItemPoolType)
33
17
  end
34
18
  local FEATURE_NAME = "get collectible item pool type"
35
19
  local initialized = false
36
- v = {run = {
37
- collectibleQueue = {},
38
- collectibleItemPoolTypeMap = __TS__New(Map),
39
- currentRoomIndex = nil,
40
- currentRoomVisitedCount = nil
41
- }}
20
+ v = {run = {collectibleItemPoolTypeMap = __TS__New(Map)}}
42
21
  function ____exports.getCollectibleItemPoolTypeInit(self, mod)
43
22
  initialized = true
44
23
  saveDataManager(nil, "getCollectibleItemPoolType", v)
45
24
  mod:AddCallback(ModCallbacks.MC_POST_PICKUP_INIT, postPickupInitCollectible, PickupVariant.PICKUP_COLLECTIBLE)
46
- mod:AddCallback(ModCallbacks.MC_PRE_GET_COLLECTIBLE, preGetCollectible)
47
25
  end
48
26
  function ____exports.getCollectibleItemPoolType(self, collectible)
49
27
  if not initialized then
@@ -56,6 +56,12 @@ export declare function isGlitchedCollectible(entity: Entity): boolean;
56
56
  */
57
57
  export declare function isPassiveCollectible(collectibleType: CollectibleType | int): boolean;
58
58
  export declare function isQuestCollectible(collectibleType: CollectibleType | int): boolean;
59
+ /**
60
+ * Helper function to determine if a particular collectible will disappear from the player's
61
+ * inventory upon use. Note that this will not work will modded items, as there is no way to
62
+ * dynamically know if a modded item will disappear.
63
+ */
64
+ export declare function isSingleUseCollectible(collectibleType: CollectibleType | int): boolean;
59
65
  /**
60
66
  * Helper function to remove all of the collectibles in the room.
61
67
  *
@@ -78,7 +84,26 @@ export declare function removeCollectiblePickupDelay(collectible: EntityPickup):
78
84
  */
79
85
  export declare function removeCollectibleFromItemTracker(collectibleType: CollectibleType | int): void;
80
86
  export declare function setCollectibleBlind(collectible: EntityPickup): void;
81
- export declare function setCollectibleSprite(collectible: EntityPickup, pngPath: string): void;
87
+ /**
88
+ * Helper function to remove the collectible from a collectible pedestal and make it appear as if a
89
+ * player has already taken the item. This is accomplished by setting its sprite to an empty/missing
90
+ * PNG file.
91
+ *
92
+ * For more information, see the documentation for the "emptySprite" helper function.
93
+ */
94
+ export declare function setCollectibleEmpty(collectible: EntityPickup): void;
95
+ /**
96
+ * Helper function to change the sprite of a collectible pedestal entity.
97
+ *
98
+ * For more information about removing the collectible sprite, see the documentation for the
99
+ * "emptySprite" helper function.
100
+ *
101
+ * @param collectible The collectible whose sprite you want to modify.
102
+ * @param pngPath Optional. Equal to the spritesheet path to load (e.g.
103
+ * "gfx/items/collectibles/collectibles_001_thesadonion.png"). If not specified, will remove the
104
+ * sprite, making it appear like the collectible has already been taken by the player.
105
+ */
106
+ export declare function setCollectibleSprite(collectible: EntityPickup, pngPath?: string): void;
82
107
  /**
83
108
  * Helper function to change the collectible on a pedestal. Simply updating the SubType property is
84
109
  * not sufficient because the sprite will not change.
@@ -1,23 +1,32 @@
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
+ local ____constants = require("constants")
6
+ local BLIND_ITEM_PNG_PATH = ____constants.BLIND_ITEM_PNG_PATH
7
+ local SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = ____constants.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES
5
8
  local ____collectibleDescriptionMap = require("maps.collectibleDescriptionMap")
6
9
  local COLLECTIBLE_DESCRIPTION_MAP = ____collectibleDescriptionMap.COLLECTIBLE_DESCRIPTION_MAP
7
10
  local ____collectibleNameMap = require("maps.collectibleNameMap")
8
11
  local COLLECTIBLE_NAME_MAP = ____collectibleNameMap.COLLECTIBLE_NAME_MAP
9
12
  local ____entity = require("functions.entity")
10
13
  local removeAllPickups = ____entity.removeAllPickups
14
+ local ____sprite = require("functions.sprite")
15
+ local clearSprite = ____sprite.clearSprite
11
16
  function ____exports.setCollectibleSprite(self, collectible, pngPath)
12
17
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
13
18
  error("You cannot set a collectible sprite for pickups of variant: " .. tostring(collectible.Variant))
14
19
  end
15
20
  local sprite = collectible:GetSprite()
16
- sprite:ReplaceSpritesheet(COLLECTIBLE_SPRITE_LAYER, pngPath)
17
- 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
18
27
  end
19
28
  COLLECTIBLE_SPRITE_LAYER = 1
20
- local BLIND_ITEM_PNG_PATH = "gfx/items/collectibles/questionmark.png"
29
+ COLLECTIBLE_SHADOW_LAYER = 4
21
30
  local GLITCHED_ITEM_THRESHOLD = 4000000000
22
31
  function ____exports.collectibleHasTag(self, collectibleType, tag)
23
32
  local itemConfig = Isaac.GetItemConfig()
@@ -136,6 +145,9 @@ end
136
145
  function ____exports.isQuestCollectible(self, collectibleType)
137
146
  return ____exports.collectibleHasTag(nil, collectibleType, 32768)
138
147
  end
148
+ function ____exports.isSingleUseCollectible(self, collectibleType)
149
+ return SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES:has(collectibleType)
150
+ end
139
151
  function ____exports.removeAllCollectibles(self, collectibleType, cap)
140
152
  removeAllPickups(nil, PickupVariant.PICKUP_COLLECTIBLE, collectibleType, cap)
141
153
  end
@@ -155,10 +167,21 @@ function ____exports.setCollectibleBlind(self, collectible)
155
167
  end
156
168
  ____exports.setCollectibleSprite(nil, collectible, BLIND_ITEM_PNG_PATH)
157
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
158
177
  function ____exports.setCollectibleSubType(self, collectible, newCollectibleType)
159
178
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
160
179
  error("You cannot set a collectible sub type for pickups of variant: " .. tostring(collectible.Variant))
161
180
  end
181
+ if newCollectibleType == CollectibleType.COLLECTIBLE_NULL then
182
+ ____exports.setCollectibleEmpty(nil, collectible)
183
+ return
184
+ end
162
185
  collectible:Morph(
163
186
  EntityType.ENTITY_PICKUP,
164
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