isaacscript-common 2.3.2 → 3.1.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 (337) hide show
  1. package/cachedClasses.d.ts +6 -4
  2. package/cachedClasses.lua +24 -0
  3. package/callbacks/customRevive.lua +2 -0
  4. package/callbacks/itemPickup.lua +2 -0
  5. package/callbacks/postBombInitLate.lua +2 -0
  6. package/callbacks/postBoneSwing.lua +2 -0
  7. package/callbacks/postCollectibleInitFirst.lua +2 -0
  8. package/callbacks/postCursedTeleport.lua +2 -0
  9. package/callbacks/postCustomDoorEnter.lua +44 -0
  10. package/callbacks/postDoorRender.lua +2 -0
  11. package/callbacks/postDoorUpdate.lua +2 -0
  12. package/callbacks/postEffectInitLate.lua +2 -0
  13. package/callbacks/postEffectStateChanged.lua +2 -0
  14. package/callbacks/postEsauJr.lua +2 -0
  15. package/callbacks/postFamiliarInitLate.lua +2 -0
  16. package/callbacks/postFamiliarStateChanged.lua +2 -0
  17. package/callbacks/postFlip.lua +2 -0
  18. package/callbacks/postGreedModeWave.lua +2 -0
  19. package/callbacks/postGridEntity.lua +2 -0
  20. package/callbacks/postGridEntityCollision.lua +2 -0
  21. package/callbacks/postGridEntityRender.lua +2 -0
  22. package/callbacks/postHolyMantleRemoved.lua +2 -0
  23. package/callbacks/postKnifeInitLate.lua +2 -0
  24. package/callbacks/postLaserInitLate.lua +2 -0
  25. package/callbacks/postNPCInitLate.lua +2 -0
  26. package/callbacks/postNPCStateChanged.lua +2 -0
  27. package/callbacks/postNewRoomEarly.lua +2 -0
  28. package/callbacks/postPickupCollect.lua +2 -0
  29. package/callbacks/postPickupInitFirst.d.ts +1 -0
  30. package/callbacks/postPickupInitFirst.lua +55 -0
  31. package/callbacks/postPickupInitLate.lua +2 -0
  32. package/callbacks/postPickupStateChanged.lua +2 -0
  33. package/callbacks/postPitRender.lua +2 -0
  34. package/callbacks/postPitUpdate.lua +2 -0
  35. package/callbacks/postPlayerChangeHealth.lua +2 -0
  36. package/callbacks/postPlayerChangeType.lua +2 -0
  37. package/callbacks/postPlayerFatalDamage.lua +2 -0
  38. package/callbacks/postPlayerInitLate.lua +2 -0
  39. package/callbacks/postPlayerReordered.lua +2 -0
  40. package/callbacks/postPoopRender.lua +2 -0
  41. package/callbacks/postPoopUpdate.lua +2 -0
  42. package/callbacks/postPressurePlateRender.lua +2 -0
  43. package/callbacks/postPressurePlateUpdate.lua +2 -0
  44. package/callbacks/postProjectileInitLate.lua +2 -0
  45. package/callbacks/postPurchase.lua +2 -0
  46. package/callbacks/postRockRender.lua +2 -0
  47. package/callbacks/postRockUpdate.lua +2 -0
  48. package/callbacks/postRoomClearChanged.lua +2 -0
  49. package/callbacks/postSacrifice.lua +2 -0
  50. package/callbacks/postSlotDestroyed.d.ts +1 -0
  51. package/callbacks/postSlotDestroyed.lua +66 -0
  52. package/callbacks/postSlotInitUpdate.lua +2 -0
  53. package/callbacks/postSlotRender.lua +5 -21
  54. package/callbacks/postSpikesRender.lua +2 -0
  55. package/callbacks/postSpikesUpdate.lua +2 -0
  56. package/callbacks/postTNTRender.lua +2 -0
  57. package/callbacks/postTNTUpdate.lua +2 -0
  58. package/callbacks/postTearInitLate.lua +2 -0
  59. package/callbacks/postTearInitVeryLate.lua +2 -0
  60. package/callbacks/postTransformation.lua +2 -0
  61. package/callbacks/postTrinketBreak.lua +2 -0
  62. package/callbacks/preBerserkDeath.lua +2 -0
  63. package/callbacks/preNewLevel.lua +2 -0
  64. package/callbacks/reorderedCallbacks.lua +16 -0
  65. package/callbacks/subscriptions/postBombInitLate.lua +6 -0
  66. package/callbacks/subscriptions/postBoneSwing.lua +6 -0
  67. package/callbacks/subscriptions/postCollectibleInitFirst.lua +6 -0
  68. package/callbacks/subscriptions/postCursedTeleport.lua +6 -0
  69. package/callbacks/subscriptions/postCustomDoorEnter.lua +6 -0
  70. package/callbacks/subscriptions/postCustomRevive.d.ts +1 -0
  71. package/callbacks/subscriptions/postCustomRevive.lua +6 -0
  72. package/callbacks/subscriptions/postDoorRender.d.ts +1 -0
  73. package/callbacks/subscriptions/postDoorRender.lua +6 -0
  74. package/callbacks/subscriptions/postDoorUpdate.d.ts +1 -0
  75. package/callbacks/subscriptions/postDoorUpdate.lua +6 -0
  76. package/callbacks/subscriptions/postEffectInitLate.lua +6 -0
  77. package/callbacks/subscriptions/postEffectStateChanged.lua +6 -0
  78. package/callbacks/subscriptions/postEsauJr.lua +6 -0
  79. package/callbacks/subscriptions/postFamiliarInitLate.lua +6 -0
  80. package/callbacks/subscriptions/postFamiliarStateChanged.lua +6 -0
  81. package/callbacks/subscriptions/postFirstEsauJr.lua +6 -0
  82. package/callbacks/subscriptions/postFirstFlip.lua +6 -0
  83. package/callbacks/subscriptions/postFlip.lua +6 -0
  84. package/callbacks/subscriptions/postGameStartedReordered.lua +6 -0
  85. package/callbacks/subscriptions/postGreedModeWave.lua +6 -0
  86. package/callbacks/subscriptions/postGridEntityBroken.lua +6 -0
  87. package/callbacks/subscriptions/postGridEntityCollision.lua +6 -0
  88. package/callbacks/subscriptions/postGridEntityInit.lua +6 -0
  89. package/callbacks/subscriptions/postGridEntityRemove.lua +6 -0
  90. package/callbacks/subscriptions/postGridEntityRender.lua +6 -0
  91. package/callbacks/subscriptions/postGridEntityStateChanged.lua +6 -0
  92. package/callbacks/subscriptions/postGridEntityUpdate.lua +6 -0
  93. package/callbacks/subscriptions/postHolyMantleRemoved.lua +6 -0
  94. package/callbacks/subscriptions/postItemDischarged.lua +6 -0
  95. package/callbacks/subscriptions/postItemPickup.lua +6 -0
  96. package/callbacks/subscriptions/postKnifeInitLate.lua +6 -0
  97. package/callbacks/subscriptions/postLaserInitLate.lua +6 -0
  98. package/callbacks/subscriptions/postNPCInitLate.lua +6 -0
  99. package/callbacks/subscriptions/postNPCStateChanged.lua +6 -0
  100. package/callbacks/subscriptions/postNewLevelReordered.lua +6 -0
  101. package/callbacks/subscriptions/postNewRoomEarly.lua +6 -0
  102. package/callbacks/subscriptions/postNewRoomReordered.lua +6 -0
  103. package/callbacks/subscriptions/postPEffectUpdateReordered.lua +6 -0
  104. package/callbacks/subscriptions/postPickupCollect.d.ts +1 -0
  105. package/callbacks/subscriptions/postPickupCollect.lua +6 -0
  106. package/callbacks/subscriptions/postPickupInitFirst.d.ts +3 -0
  107. package/callbacks/subscriptions/postPickupInitFirst.lua +29 -0
  108. package/callbacks/subscriptions/postPickupInitLate.lua +6 -0
  109. package/callbacks/subscriptions/postPickupStateChanged.d.ts +1 -0
  110. package/callbacks/subscriptions/postPickupStateChanged.lua +6 -0
  111. package/callbacks/subscriptions/postPitRender.d.ts +1 -0
  112. package/callbacks/subscriptions/postPitRender.lua +6 -0
  113. package/callbacks/subscriptions/postPitUpdate.d.ts +1 -0
  114. package/callbacks/subscriptions/postPitUpdate.lua +6 -0
  115. package/callbacks/subscriptions/postPlayerChangeHealth.lua +6 -0
  116. package/callbacks/subscriptions/postPlayerChangeType.lua +6 -0
  117. package/callbacks/subscriptions/postPlayerFatalDamage.lua +6 -0
  118. package/callbacks/subscriptions/postPlayerInitLate.lua +6 -0
  119. package/callbacks/subscriptions/postPlayerInitReordered.lua +6 -0
  120. package/callbacks/subscriptions/postPlayerRenderReordered.lua +6 -0
  121. package/callbacks/subscriptions/postPlayerUpdateReordered.lua +6 -0
  122. package/callbacks/subscriptions/postPoopRender.d.ts +1 -0
  123. package/callbacks/subscriptions/postPoopRender.lua +6 -0
  124. package/callbacks/subscriptions/postPoopUpdate.d.ts +1 -0
  125. package/callbacks/subscriptions/postPoopUpdate.lua +6 -0
  126. package/callbacks/subscriptions/postPressurePlateRender.d.ts +1 -0
  127. package/callbacks/subscriptions/postPressurePlateRender.lua +6 -0
  128. package/callbacks/subscriptions/postPressurePlateUpdate.d.ts +1 -0
  129. package/callbacks/subscriptions/postPressurePlateUpdate.lua +6 -0
  130. package/callbacks/subscriptions/postProjectileInitLate.lua +6 -0
  131. package/callbacks/subscriptions/postPurchase.lua +6 -0
  132. package/callbacks/subscriptions/postRockRender.d.ts +1 -0
  133. package/callbacks/subscriptions/postRockRender.lua +6 -0
  134. package/callbacks/subscriptions/postRockUpdate.d.ts +1 -0
  135. package/callbacks/subscriptions/postRockUpdate.lua +6 -0
  136. package/callbacks/subscriptions/postRoomClearChanged.lua +6 -0
  137. package/callbacks/subscriptions/postSacrifice.lua +6 -0
  138. package/callbacks/subscriptions/postSlotAnimationChanged.lua +6 -0
  139. package/callbacks/subscriptions/postSlotDestroyed.lua +6 -0
  140. package/callbacks/subscriptions/postSlotInit.lua +6 -0
  141. package/callbacks/subscriptions/postSlotRender.lua +6 -0
  142. package/callbacks/subscriptions/postSlotUpdate.lua +6 -0
  143. package/callbacks/subscriptions/postSpikesRender.d.ts +1 -0
  144. package/callbacks/subscriptions/postSpikesRender.lua +6 -0
  145. package/callbacks/subscriptions/postSpikesUpdate.d.ts +1 -0
  146. package/callbacks/subscriptions/postSpikesUpdate.lua +6 -0
  147. package/callbacks/subscriptions/postTNTRender.d.ts +1 -0
  148. package/callbacks/subscriptions/postTNTRender.lua +6 -0
  149. package/callbacks/subscriptions/postTNTUpdate.d.ts +1 -0
  150. package/callbacks/subscriptions/postTNTUpdate.lua +6 -0
  151. package/callbacks/subscriptions/postTearInitLate.lua +6 -0
  152. package/callbacks/subscriptions/postTearInitVeryLate.lua +6 -0
  153. package/callbacks/subscriptions/postTransformation.lua +6 -0
  154. package/callbacks/subscriptions/postTrinketBreak.lua +6 -0
  155. package/callbacks/subscriptions/preBerserkDeath.lua +6 -0
  156. package/callbacks/subscriptions/preCustomRevive.lua +6 -0
  157. package/callbacks/subscriptions/preItemPickup.lua +6 -0
  158. package/callbacks/subscriptions/preNewLevel.lua +6 -0
  159. package/classes/DefaultMap.d.ts +70 -39
  160. package/classes/DefaultMap.lua +94 -43
  161. package/classes/ModUpgraded.d.ts +3 -3
  162. package/classes/ModUpgraded.lua +5 -0
  163. package/constants.lua +41 -0
  164. package/constantsFirstLast.lua +63 -0
  165. package/enums/HealthType.lua +3 -0
  166. package/enums/ModCallbackCustom.d.ts +62 -40
  167. package/enums/ModCallbackCustom.lua +46 -38
  168. package/enums/private/CopyableIsaacAPIClassType.lua +1 -0
  169. package/enums/private/SerializationBrand.lua +5 -0
  170. package/features/characterHealthConversion.lua +6 -0
  171. package/features/characterStats.lua +17 -0
  172. package/features/debugDisplay/exports.d.ts +17 -0
  173. package/features/debugDisplay/exports.lua +90 -0
  174. package/features/debugDisplay/v.d.ts +17 -0
  175. package/features/deployJSONRoom.d.ts +1 -0
  176. package/features/deployJSONRoom.lua +56 -0
  177. package/features/disableInputs.lua +45 -0
  178. package/features/disableSound.lua +14 -0
  179. package/features/extraConsoleCommands/commandsDisplay.lua +90 -0
  180. package/features/extraConsoleCommands/init.lua +16 -0
  181. package/features/extraConsoleCommands/listCommands.lua +172 -0
  182. package/features/fadeInRemover.lua +10 -0
  183. package/features/fastReset.lua +10 -0
  184. package/features/forgottenSwitch.lua +4 -0
  185. package/features/getCollectibleItemPoolType.lua +5 -0
  186. package/features/playerInventory.lua +18 -0
  187. package/features/ponyDetection.lua +4 -0
  188. package/features/preventCollectibleRotation.lua +9 -0
  189. package/features/runInNFrames.lua +50 -0
  190. package/features/saveDataManager/constants.lua +1 -0
  191. package/features/saveDataManager/exports.lua +115 -0
  192. package/features/saveDataManager/load.lua +12 -8
  193. package/features/saveDataManager/main.lua +16 -3
  194. package/features/saveDataManager/maps.lua +3 -0
  195. package/features/saveDataManager/merge.lua +53 -21
  196. package/features/saveDataManager/save.lua +12 -7
  197. package/features/sirenHelpers.lua +13 -0
  198. package/features/taintedLazarusPlayers.lua +11 -0
  199. package/featuresInitialized.lua +6 -0
  200. package/functions/array.d.ts +2 -0
  201. package/functions/array.lua +85 -0
  202. package/functions/benchmark.lua +6 -0
  203. package/functions/bombs.d.ts +3 -0
  204. package/functions/bombs.lua +12 -0
  205. package/functions/boss.lua +35 -0
  206. package/functions/cacheFlag.lua +4 -0
  207. package/functions/cards.lua +60 -0
  208. package/functions/challenges.lua +1 -0
  209. package/functions/character.lua +23 -0
  210. package/functions/charge.lua +39 -0
  211. package/functions/chargeBar.d.ts +1 -0
  212. package/functions/chargeBar.lua +4 -0
  213. package/functions/collectibleCacheFlag.lua +15 -0
  214. package/functions/collectibleSet.lua +3 -0
  215. package/functions/collectibleTag.lua +9 -0
  216. package/functions/collectibles.d.ts +13 -8
  217. package/functions/collectibles.lua +147 -3
  218. package/functions/color.lua +18 -0
  219. package/functions/debug.lua +18 -0
  220. package/functions/deepCopy.lua +60 -26
  221. package/functions/deepCopyTests.lua +8 -5
  222. package/functions/direction.d.ts +8 -0
  223. package/functions/direction.lua +27 -0
  224. package/functions/doors.d.ts +1 -0
  225. package/functions/doors.lua +58 -0
  226. package/functions/entity.d.ts +4 -4
  227. package/functions/entity.lua +94 -6
  228. package/functions/entitySpecific.d.ts +20 -20
  229. package/functions/entitySpecific.lua +182 -0
  230. package/functions/entityTypes.d.ts +1 -1
  231. package/functions/entityTypes.lua +1 -0
  232. package/functions/enums.d.ts +2 -0
  233. package/functions/enums.lua +62 -0
  234. package/functions/familiars.lua +52 -0
  235. package/functions/flag.lua +77 -0
  236. package/functions/flying.lua +10 -0
  237. package/functions/globals.lua +8 -10
  238. package/functions/gridEntity.lua +105 -0
  239. package/functions/gridEntitySpecific.d.ts +5 -0
  240. package/functions/gridEntitySpecific.lua +8 -0
  241. package/functions/input.lua +11 -0
  242. package/functions/isaacAPIClass.d.ts +4 -4
  243. package/functions/isaacAPIClass.lua +15 -3
  244. package/functions/jsonHelpers.lua +11 -0
  245. package/functions/jsonRoom.d.ts +2 -0
  246. package/functions/jsonRoom.lua +5 -0
  247. package/functions/kColor.lua +9 -0
  248. package/functions/language.lua +5 -0
  249. package/functions/log.lua +31 -3
  250. package/functions/map.lua +18 -0
  251. package/functions/math.lua +26 -0
  252. package/functions/npc.lua +24 -0
  253. package/functions/pickupVariants.d.ts +11 -11
  254. package/functions/pickupVariants.lua +11 -0
  255. package/functions/pickups.d.ts +9 -9
  256. package/functions/pickups.lua +67 -0
  257. package/functions/pills.lua +45 -0
  258. package/functions/player.d.ts +7 -0
  259. package/functions/player.lua +210 -9
  260. package/functions/playerDataStructures.lua +65 -0
  261. package/functions/playerHealth.d.ts +3 -0
  262. package/functions/playerHealth.lua +92 -63
  263. package/functions/playerIndex.d.ts +2 -0
  264. package/functions/playerIndex.lua +47 -0
  265. package/functions/pocketItems.lua +18 -0
  266. package/functions/positionVelocity.d.ts +3 -0
  267. package/functions/positionVelocity.lua +46 -0
  268. package/functions/random.d.ts +2 -0
  269. package/functions/random.lua +32 -0
  270. package/functions/revive.d.ts +2 -0
  271. package/functions/revive.lua +15 -0
  272. package/functions/rng.d.ts +1 -0
  273. package/functions/rng.lua +19 -0
  274. package/functions/roomData.lua +68 -0
  275. package/functions/roomGrid.lua +21 -0
  276. package/functions/roomShape.lua +22 -0
  277. package/functions/rooms.lua +100 -0
  278. package/functions/run.lua +5 -0
  279. package/functions/seeds.lua +4 -0
  280. package/functions/serialization.lua +6 -2
  281. package/functions/set.d.ts +1 -0
  282. package/functions/set.lua +22 -0
  283. package/functions/spawnCollectible.lua +24 -0
  284. package/functions/sprite.d.ts +2 -0
  285. package/functions/sprite.lua +25 -0
  286. package/functions/stage.lua +16 -0
  287. package/functions/string.lua +6 -0
  288. package/functions/table.d.ts +12 -0
  289. package/functions/table.lua +53 -0
  290. package/functions/tears.d.ts +1 -0
  291. package/functions/tears.lua +12 -0
  292. package/functions/transformations.lua +18 -0
  293. package/functions/trinketCacheFlag.lua +3 -0
  294. package/functions/trinketGive.lua +24 -0
  295. package/functions/trinkets.lua +52 -0
  296. package/functions/tstlClass.d.ts +34 -0
  297. package/functions/tstlClass.lua +63 -9
  298. package/functions/ui.d.ts +2 -0
  299. package/functions/ui.lua +16 -0
  300. package/functions/utils.d.ts +16 -0
  301. package/functions/utils.lua +108 -0
  302. package/functions/vector.lua +13 -16
  303. package/index.d.ts +1 -0
  304. package/index.lua +8 -0
  305. package/initCustomCallbacks.lua +6 -0
  306. package/interfaces/AddCallbackParameterCustom.d.ts +2 -0
  307. package/interfaces/ChargeBarSprites.d.ts +1 -0
  308. package/interfaces/private/TSTLClassMetatable.d.ts +2 -0
  309. package/lualib_bundle.lua +21 -34
  310. package/maps/cardMap.lua +1 -0
  311. package/maps/characterMap.lua +1 -0
  312. package/maps/defaultPlayerStatMap.lua +1 -0
  313. package/maps/gridEntityXMLMap.lua +2 -0
  314. package/maps/pillEffectMap.lua +1 -0
  315. package/maps/roomShapeToTopLeftWallGridIndexMap.lua +2 -0
  316. package/maps/roomTypeMap.lua +1 -0
  317. package/objects/LRoomShapeToRectangles.lua +2 -0
  318. package/objects/callbackRegisterFunctions.lua +3 -0
  319. package/objects/colors.lua +4 -0
  320. package/objects/oppositeDoorSlots.d.ts +4 -0
  321. package/objects/oppositeDoorSlots.lua +15 -0
  322. package/objects/roomShapeBounds.lua +2 -0
  323. package/objects/roomShapeLayoutSizes.lua +4 -0
  324. package/objects/roomShapeToBottomRightPosition.lua +2 -0
  325. package/objects/roomShapeToDoorSlotsToGridIndexDelta.lua +2 -0
  326. package/objects/roomShapeToTopLeftPosition.lua +2 -0
  327. package/objects/roomShapeVolumes.lua +3 -0
  328. package/package.json +2 -2
  329. package/patchErrorFunctions.lua +8 -0
  330. package/sets/bossSets.lua +23 -0
  331. package/sets/charactersWithNoRedHeartsSet.lua +2 -0
  332. package/sets/charactersWithNoSoulHeartsSet.lua +2 -0
  333. package/sets/lostStyleCharactersSet.lua +2 -0
  334. package/types/AnyEntity.d.ts +10 -0
  335. package/types/PickingUpItem.lua +7 -0
  336. package/upgradeMod.d.ts +4 -4
  337. package/upgradeMod.lua +18 -0
@@ -13,6 +13,19 @@ local ____collectibles = require("functions.collectibles")
13
13
  local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
14
14
  local ____playerIndex = require("functions.playerIndex")
15
15
  local getPlayers = ____playerIndex.getPlayers
16
+ --- Helper function to add a charge to one of a player's active items, emulating what happens when a
17
+ -- room is cleared.
18
+ --
19
+ -- This function will take the following things into account:
20
+ -- - L rooms and 2x2 rooms granting a double charge
21
+ -- - The Battery
22
+ -- - AAA Battery
23
+ --
24
+ -- @param player The player to grant the charges to.
25
+ -- @param activeSlot The active item slot to grant the charges to.
26
+ -- @param ignoreBigRoomDoubleCharge Optional. If set to true, it will treat the current room as a
27
+ -- 1x1 room for the purposes of calculating how much charge to
28
+ -- grant. Default is false.
16
29
  function ____exports.addRoomClearChargeToSlot(self, player, activeSlot, ignoreBigRoomDoubleCharge)
17
30
  if ignoreBigRoomDoubleCharge == nil then
18
31
  ignoreBigRoomDoubleCharge = false
@@ -75,6 +88,9 @@ function getNumChargesWithAAAModifier(self, player, activeSlot, chargesToAdd)
75
88
  end
76
89
  return chargesToAdd
77
90
  end
91
+ --- Helper function to get the combined normal charge and the battery charge for the player's active
92
+ -- item. This is useful because you have to add these two values together when setting the active
93
+ -- charge.
78
94
  function ____exports.getTotalCharge(self, player, activeSlot)
79
95
  local activeCharge = player:GetActiveCharge(activeSlot)
80
96
  local batteryCharge = player:GetBatteryCharge(activeSlot)
@@ -98,6 +114,18 @@ function shouldPlayFullRechargeSound(self, player, activeSlot)
98
114
  end
99
115
  return not player:NeedsCharge(activeSlot) or activeCharge == maxCharges and batteryCharge == 0
100
116
  end
117
+ --- Helper function to add a charge to a player's active item, emulating what happens when a room is
118
+ -- cleared.
119
+ --
120
+ -- This function will take the following things into account:
121
+ -- - L rooms and 2x2 rooms granting a double charge
122
+ -- - The Battery
123
+ -- - AAA Battery
124
+ --
125
+ -- @param player The player to grant the charges to.
126
+ -- @param ignoreBigRoomDoubleCharge Optional. If set to true, it will treat the current room as a
127
+ -- 1x1 room for the purposes of calculating how much charge to
128
+ -- grant. Default is false.
101
129
  function ____exports.addRoomClearCharge(self, player, ignoreBigRoomDoubleCharge)
102
130
  if ignoreBigRoomDoubleCharge == nil then
103
131
  ignoreBigRoomDoubleCharge = false
@@ -106,6 +134,17 @@ function ____exports.addRoomClearCharge(self, player, ignoreBigRoomDoubleCharge)
106
134
  ____exports.addRoomClearChargeToSlot(nil, player, activeSlot, ignoreBigRoomDoubleCharge)
107
135
  end
108
136
  end
137
+ --- Helper function to add a charge to every player's active item, emulating what happens when a room
138
+ -- is cleared.
139
+ --
140
+ -- This function will take the following things into account:
141
+ -- - L rooms and 2x2 rooms granting a double charge
142
+ -- - The Battery
143
+ -- - AAA Battery
144
+ --
145
+ -- @param ignoreBigRoomDoubleCharge Optional. If set to true, it will treat the current room as a
146
+ -- 1x1 room for the purposes of calculating how much charge to
147
+ -- grant. Default is false.
109
148
  function ____exports.addRoomClearCharges(self, ignoreBigRoomDoubleCharge)
110
149
  if ignoreBigRoomDoubleCharge == nil then
111
150
  ignoreBigRoomDoubleCharge = false
@@ -1,4 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
2
3
  import { ChargeBarSprites } from "../interfaces/ChargeBarSprites";
3
4
  /**
4
5
  * Constructor for a `ChargeBarSprites` object. For more information, see the `renderChargeBar`
@@ -8,6 +8,8 @@ function getChargeBarClamp(self, charges, maxCharges)
8
8
  return Vector(0, meterClip)
9
9
  end
10
10
  local CHARGE_BAR_ANM2 = "gfx/ui/ui_chargebar.anm2"
11
+ --- Constructor for a `ChargeBarSprites` object. For more information, see the `renderChargeBar`
12
+ -- helper function.
11
13
  function ____exports.newChargeBarSprites(self, maxCharges)
12
14
  local back = Sprite()
13
15
  back:Load(CHARGE_BAR_ANM2, true)
@@ -32,6 +34,8 @@ function ____exports.newChargeBarSprites(self, maxCharges)
32
34
  maxCharges = maxCharges
33
35
  }
34
36
  end
37
+ --- Helper function to render a charge bar on the screen. First, call the `newChargeBarSprites`
38
+ -- function to initialize the sprites, and then call this function on every render frame.
35
39
  function ____exports.renderChargeBar(self, sprites, position, normalCharges, batteryCharges)
36
40
  sprites.back:Render(position, VectorZero, VectorZero)
37
41
  local normalChargesClamp = getChargeBarClamp(nil, normalCharges, sprites.maxCharges)
@@ -37,6 +37,8 @@ local function initCacheFlagMap(self)
37
37
  CACHE_FLAG_TO_COLLECTIBLES_MAP:set(cacheFlag, collectiblesSet)
38
38
  end
39
39
  end
40
+ --- Returns a set containing every collectible type with the given cache flag, including modded
41
+ -- collectibles.
40
42
  function ____exports.getCollectiblesForCacheFlag(self, cacheFlag)
41
43
  if CACHE_FLAG_TO_COLLECTIBLES_MAP.size == 0 then
42
44
  initCacheFlagMap(nil)
@@ -47,6 +49,19 @@ function ____exports.getCollectiblesForCacheFlag(self, cacheFlag)
47
49
  end
48
50
  return copySet(nil, collectiblesSet)
49
51
  end
52
+ --- Returns an array containing every collectible type that the player has that matches the provided
53
+ -- CacheFlag.
54
+ --
55
+ -- For example, if the cache flag is `CacheFlag.FLYING`, and the player has one Lord of the Pit and
56
+ -- two Dead Doves, then this function would return:
57
+ --
58
+ -- ```ts
59
+ -- [
60
+ -- CollectibleType.LORD_OF_THE_PIT,
61
+ -- CollectibleType.DEAD_DOVE,
62
+ -- CollectibleType.DEAD_DOVE,
63
+ -- ]
64
+ -- ```
50
65
  function ____exports.getPlayerCollectiblesForCacheFlag(self, player, cacheFlag)
51
66
  local collectiblesForCacheFlag = ____exports.getCollectiblesForCacheFlag(nil, cacheFlag)
52
67
  local playerCollectibles = {}
@@ -30,18 +30,21 @@ local function initCollectibleSets(self)
30
30
  ::__continue3::
31
31
  end
32
32
  end
33
+ --- Returns a set containing every valid collectible type in the game, including modded collectibles.
33
34
  function ____exports.getCollectibleSet(self)
34
35
  if ALL_COLLECTIBLES_SET.size == 0 then
35
36
  initCollectibleSets(nil)
36
37
  end
37
38
  return copySet(nil, ALL_COLLECTIBLES_SET)
38
39
  end
40
+ --- Returns a set containing every modded collectible type in the game.
39
41
  function ____exports.getModdedCollectibleSet(self)
40
42
  if ALL_COLLECTIBLES_SET.size == 0 then
41
43
  initCollectibleSets(nil)
42
44
  end
43
45
  return copySet(nil, MODDED_COLLECTIBLES_SET)
44
46
  end
47
+ --- Returns a set containing every valid vanilla collectible type in the game.
45
48
  function ____exports.getVanillaCollectibleSet(self)
46
49
  if ALL_COLLECTIBLES_SET.size == 0 then
47
50
  initCollectibleSets(nil)
@@ -50,6 +50,14 @@ local function initTagMap(self)
50
50
  end
51
51
  end
52
52
  end
53
+ --- Helper function to get all of the collectible types in the game that have a certain tag.
54
+ --
55
+ -- For example, to get all of the collectible types that count as offensive for the purposes of
56
+ -- Tainted Lost:
57
+ --
58
+ -- ```ts
59
+ -- const offensiveCollectibleTypes = getCollectibleTypesWithTag(ItemConfigTag.OFFENSIVE);
60
+ -- ```
53
61
  function ____exports.getCollectibleTypesWithTag(self, itemConfigTag)
54
62
  if TAG_TO_COLLECTIBLE_TYPES_MAP.size == 0 then
55
63
  initTagMap(nil)
@@ -60,6 +68,7 @@ function ____exports.getCollectibleTypesWithTag(self, itemConfigTag)
60
68
  end
61
69
  return copySet(nil, collectibleTypes)
62
70
  end
71
+ --- Returns the number of items that a player has towards a particular transformation.
63
72
  function ____exports.getPlayerNumCollectiblesWithTag(self, player, itemConfigTag)
64
73
  local collectibleTypesSet = ____exports.getCollectibleTypesWithTag(nil, itemConfigTag)
65
74
  return getPlayerCollectibleCount(
@@ -8,9 +8,14 @@ export declare function collectibleSpriteEquals(sprite1: Sprite, sprite2: Sprite
8
8
  * provided collectible type was not valid.
9
9
  */
10
10
  export declare function getCollectibleDescription(collectibleType: CollectibleType): string;
11
+ /**
12
+ * Helper function to get the coin cost that a collectible item would be if it were being offered in
13
+ * a Devil Room deal. Returns 0 if passed `CollectibleType.NULL`.
14
+ */
15
+ export declare function getCollectibleDevilCoinPrice(collectibleType: CollectibleType): int;
11
16
  /**
12
17
  * Helper function to get the heart cost that a collectible item would be if it were being offered
13
- * in a Devil Room deal. Returns 0 if passed CollectibleType.NULL.
18
+ * in a Devil Room deal. Returns 0 if passed `CollectibleType.NULL`.
14
19
  */
15
20
  export declare function getCollectibleDevilHeartPrice(collectibleType: CollectibleType, player: EntityPlayer): PickupPrice;
16
21
  /**
@@ -47,13 +52,13 @@ export declare function getCollectibleGfxFilename(collectibleType: CollectibleTy
47
52
  * and the pedestal pushed to an adjacent tile, but this case should be extremely rare.)
48
53
  * - Mega Chests spawn two collectibles on the exact same position. However, both of them will have
49
54
  * different InitSeeds, so this is not a problem for this indexing scheme.
50
- * - The indexing scheme used is different for collectibles that are inside of a Treasure Room, in
51
- * order to handle the case of the player seeing the same collectible again in a post-Ascent
52
- * Treasure Room. A 5-tuple of stage, stage type, grid index, SubType, and InitSeed is used in
53
- * this case. (Using the room list index or the room grid index is not suitable for this purpose,
54
- * since both of these values can change in the post-Ascent Treasure Room.) Even though there can
55
- * be two Treasure Rooms on an XL floor, both Treasure Rooms should not have collectibles with the
56
- * same grid index, Subtype, and InitSeed.
55
+ * - The indexing scheme used is different for collectibles that are inside of a Treasure Room or
56
+ * Boss Room, in order to handle the case of the player seeing the same collectible again in a
57
+ * post-Ascent Treasure Room or Boss Room. A 5-tuple of stage, stage type, grid index, SubType,
58
+ * and InitSeed is used in this case. (Using the room list index or the room grid index is not
59
+ * suitable for this purpose, since both of these values can change in the post-Ascent rooms.)
60
+ * Even though Treasure Rooms and Boss Rooms are grouped together in this scheme, there probably
61
+ * will not be collectibles with the same grid index, SubType, and InitSeed.
57
62
  */
58
63
  export declare function getCollectibleIndex(collectible: EntityPickup): CollectibleIndex;
59
64
  /**
@@ -44,6 +44,16 @@ function initQuestionMarkSprite(self)
44
44
  sprite:LoadGraphics()
45
45
  return sprite
46
46
  end
47
+ --- Helper function to change the sprite of a collectible pedestal entity.
48
+ --
49
+ -- For more information about removing the collectible sprite, see the documentation for the
50
+ -- "clearSprite" helper function.
51
+ --
52
+ -- @param collectible The collectible whose sprite you want to modify.
53
+ -- @param pngPath Equal to either the spritesheet path to load (e.g.
54
+ -- "gfx/items/collectibles/collectibles_001_thesadonion.png") or undefined. If
55
+ -- undefined, the sprite will be removed, making it appear like the collectible has
56
+ -- already been taken by the player.
47
57
  function ____exports.setCollectibleSprite(self, collectible, pngPath)
48
58
  if not isCollectible(nil, collectible) then
49
59
  local entityID = getEntityID(nil, collectible)
@@ -64,6 +74,7 @@ local questionMarkSprite = initQuestionMarkSprite(nil)
64
74
  function ____exports.clearCollectibleSprite(self, collectible)
65
75
  ____exports.setCollectibleSprite(nil, collectible, nil)
66
76
  end
77
+ --- Helper function to check if two collectible sprites have the same sprite sheet loaded.
67
78
  function ____exports.collectibleSpriteEquals(self, sprite1, sprite2)
68
79
  local xStart = -1
69
80
  local xFinish = 1
@@ -84,6 +95,8 @@ function ____exports.collectibleSpriteEquals(self, sprite1, sprite2)
84
95
  yIncrement
85
96
  )
86
97
  end
98
+ --- Helper function to get the in-game description for a collectible. Returns "Unknown" if the
99
+ -- provided collectible type was not valid.
87
100
  function ____exports.getCollectibleDescription(self, collectibleType)
88
101
  local collectibleDescription = COLLECTIBLE_DESCRIPTION_MAP:get(collectibleType)
89
102
  if collectibleDescription ~= nil then
@@ -95,6 +108,21 @@ function ____exports.getCollectibleDescription(self, collectibleType)
95
108
  end
96
109
  return DEFAULT_COLLECTIBLE_DESCRIPTION
97
110
  end
111
+ --- Helper function to get the coin cost that a collectible item would be if it were being offered in
112
+ -- a Devil Room deal. Returns 0 if passed `CollectibleType.NULL`.
113
+ function ____exports.getCollectibleDevilCoinPrice(self, collectibleType)
114
+ if collectibleType == CollectibleType.NULL then
115
+ return 0
116
+ end
117
+ local defaultCollectiblePrice = 15
118
+ local itemConfigItem = itemConfig:GetCollectible(collectibleType)
119
+ if itemConfigItem == nil then
120
+ return defaultCollectiblePrice
121
+ end
122
+ return itemConfigItem.DevilPrice * defaultCollectiblePrice
123
+ end
124
+ --- Helper function to get the heart cost that a collectible item would be if it were being offered
125
+ -- in a Devil Room deal. Returns 0 if passed `CollectibleType.NULL`.
98
126
  function ____exports.getCollectibleDevilHeartPrice(self, collectibleType, player)
99
127
  local maxHearts = player:GetMaxHearts()
100
128
  if collectibleType == CollectibleType.NULL then
@@ -103,14 +131,16 @@ function ____exports.getCollectibleDevilHeartPrice(self, collectibleType, player
103
131
  if maxHearts == 0 then
104
132
  return PickupPrice.THREE_SOUL_HEARTS
105
133
  end
106
- local defaultPickupPrice = PickupPrice.ONE_HEART
134
+ local defaultCollectiblePrice = PickupPrice.ONE_HEART
107
135
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
108
136
  if itemConfigItem == nil then
109
- return defaultPickupPrice
137
+ return defaultCollectiblePrice
110
138
  end
111
139
  local twoHeartPrice = maxHearts == 2 and PickupPrice.ONE_HEART_AND_TWO_SOUL_HEARTS or PickupPrice.TWO_HEARTS
112
140
  return itemConfigItem.DevilPrice == 2 and twoHeartPrice or PickupPrice.ONE_HEART
113
141
  end
142
+ --- Helper function to get the path to a collectible's sprite. Returns the path to the question mark
143
+ -- sprite (i.e. from Curse of the Blind) if the provided collectible type was not valid.
114
144
  function ____exports.getCollectibleGfxFilename(self, collectibleType)
115
145
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
116
146
  if itemConfigItem == nil then
@@ -118,6 +148,41 @@ function ____exports.getCollectibleGfxFilename(self, collectibleType)
118
148
  end
119
149
  return itemConfigItem.GfxFileName
120
150
  end
151
+ --- Mods often have to track variables relating to a collectible. Finding an index for these kinds of
152
+ -- data structures is difficult, since collectibles are respawned every time a player re-enters a
153
+ -- room, so the `PtrHash` will change. Instead, we use a 4-tuple of the room list index, the grid
154
+ -- index of the collectible in the room, the collectible's SubType, and the collectible's InitSeed.
155
+ --
156
+ -- Collectibles that are shifted by Tainted Isaac's mechanic will have unique collectible indexes
157
+ -- because the SubType is different. (The collectible entities share the same InitSeed.)
158
+ --
159
+ -- Collectibles that are rolled (with e.g. a D6) will have unique collectible indexes because the
160
+ -- SubType and InitSeed are different. If you want to track collectibles independently of any
161
+ -- rerolls, then you can use the `PtrHash` as an index instead. (The `PtrHash` will not persist
162
+ -- between rooms, however.)
163
+ --
164
+ -- Note that:
165
+ -- - The grid index is a necessary part of the collectible index because Diplopia and Crooked Penny
166
+ -- can cause two or more collectibles with the same SubType and InitSeed to exist in the same
167
+ -- room.
168
+ -- - This index will fail in the case where the player uses Diplopia or a successful Crooked Penny
169
+ -- seven or more times in the same room, since that will cause two or more collectibles with the
170
+ -- same grid index, SubType, and InitSeed to exist.
171
+ -- - The SubType is a necessary part of the collectible index because Tainted Isaac will
172
+ -- continuously cause collectibles to morph into new sub-types with the same InitSeed.
173
+ -- - Using a collectible's position as part of the index is problematic, since players can push a
174
+ -- pedestal. (Even using the grid index does not solve this problem, since it is possible in
175
+ -- certain cases for collectibles to be spawned at a position that is not aligned with the grid,
176
+ -- and the pedestal pushed to an adjacent tile, but this case should be extremely rare.)
177
+ -- - Mega Chests spawn two collectibles on the exact same position. However, both of them will have
178
+ -- different InitSeeds, so this is not a problem for this indexing scheme.
179
+ -- - The indexing scheme used is different for collectibles that are inside of a Treasure Room or
180
+ -- Boss Room, in order to handle the case of the player seeing the same collectible again in a
181
+ -- post-Ascent Treasure Room or Boss Room. A 5-tuple of stage, stage type, grid index, SubType,
182
+ -- and InitSeed is used in this case. (Using the room list index or the room grid index is not
183
+ -- suitable for this purpose, since both of these values can change in the post-Ascent rooms.)
184
+ -- Even though Treasure Rooms and Boss Rooms are grouped together in this scheme, there probably
185
+ -- will not be collectibles with the same grid index, SubType, and InitSeed.
121
186
  function ____exports.getCollectibleIndex(self, collectible)
122
187
  if not isCollectible(nil, collectible) then
123
188
  local entityID = getEntityID(nil, collectible)
@@ -130,11 +195,13 @@ function ____exports.getCollectibleIndex(self, collectible)
130
195
  local roomType = room:GetType()
131
196
  local gridIndex = room:GetGridIndex(collectible.Position)
132
197
  local roomListIndex = getRoomListIndex(nil)
133
- if roomType == RoomType.TREASURE then
198
+ if roomType == RoomType.TREASURE or roomType == RoomType.BOSS then
134
199
  return (((((((tostring(stage) .. ",") .. tostring(stageType)) .. ",") .. tostring(gridIndex)) .. ",") .. tostring(collectible.SubType)) .. ",") .. tostring(collectible.InitSeed)
135
200
  end
136
201
  return (((((tostring(roomListIndex) .. ",") .. tostring(gridIndex)) .. ",") .. tostring(collectible.SubType)) .. ",") .. tostring(collectible.InitSeed)
137
202
  end
203
+ --- Helper function to get the initial amount of charges that a collectible has. Returns 0 if the
204
+ -- provided collectible type was not valid.
138
205
  function ____exports.getCollectibleInitCharge(self, collectibleType)
139
206
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
140
207
  if itemConfigItem == nil then
@@ -142,6 +209,8 @@ function ____exports.getCollectibleInitCharge(self, collectibleType)
142
209
  end
143
210
  return itemConfigItem.InitCharge
144
211
  end
212
+ --- Helper function to get the `ItemType` of a collectible. Returns `ItemType.ITEM_NULL` if the
213
+ -- provided collectible type was not valid.
145
214
  function ____exports.getCollectibleItemType(self, collectibleType)
146
215
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
147
216
  if itemConfigItem == nil then
@@ -149,6 +218,8 @@ function ____exports.getCollectibleItemType(self, collectibleType)
149
218
  end
150
219
  return itemConfigItem.Type
151
220
  end
221
+ --- Helper function to get the maximum amount of charges that a collectible has. Returns 0 if the
222
+ -- provided collectible type was not valid.
152
223
  function ____exports.getCollectibleMaxCharges(self, collectibleType)
153
224
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
154
225
  if itemConfigItem == nil then
@@ -156,6 +227,15 @@ function ____exports.getCollectibleMaxCharges(self, collectibleType)
156
227
  end
157
228
  return itemConfigItem.MaxCharges
158
229
  end
230
+ --- Helper function to get the name of a collectible. Returns "Unknown" if the provided collectible
231
+ -- type is not valid.
232
+ --
233
+ -- For example:
234
+ --
235
+ -- ```ts
236
+ -- const collectibleType = CollectibleType.SAD_ONION;
237
+ -- const collectibleName = getCollectibleName(collectibleType); // collectibleName is "Sad Onion"
238
+ -- ```
159
239
  function ____exports.getCollectibleName(self, collectibleType)
160
240
  local collectibleName = COLLECTIBLE_NAME_MAP:get(collectibleType)
161
241
  if collectibleName ~= nil then
@@ -175,6 +255,8 @@ function ____exports.getCollectiblePedestalType(self, collectible)
175
255
  local sprite = collectible:GetSprite()
176
256
  return sprite:GetOverlayFrame()
177
257
  end
258
+ --- Helper function to get the path to a collectible's quality. Returns 0 if the provided collectible
259
+ -- type was not valid.
178
260
  function ____exports.getCollectibleQuality(self, collectibleType)
179
261
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
180
262
  if itemConfigItem == nil then
@@ -182,26 +264,59 @@ function ____exports.getCollectibleQuality(self, collectibleType)
182
264
  end
183
265
  return itemConfigItem.Quality
184
266
  end
267
+ --- Helper function to get the tags of a collectible (which is the composition of zero or more
268
+ -- `ItemConfigTag`). Returns 0 if the provided collectible type is not valid.
269
+ --
270
+ -- For example:
271
+ --
272
+ -- ```ts
273
+ -- const collectibleType = CollectibleType.SAD_ONION;
274
+ -- const itemConfigTags = getCollectibleTags(collectibleType); // itemConfigTags is "18350080"
275
+ -- ```
185
276
  function ____exports.getCollectibleTags(self, collectibleType)
186
277
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
187
278
  return itemConfigItem == nil and ItemConfigTagZero or itemConfigItem.Tags
188
279
  end
280
+ --- Helper function to get an array that represents the range from the first collectible type to the
281
+ -- last collectible type. This will include integers that do not represent any valid collectible
282
+ -- types.
283
+ --
284
+ -- This function is only useful when building collectible type objects. For most purposes, you
285
+ -- should use the `getCollectibleSet` helper function instead.
189
286
  function ____exports.getCollectibleTypeRange(self)
190
287
  return irange(nil, FIRST_COLLECTIBLE_TYPE, LAST_COLLECTIBLE_TYPE)
191
288
  end
289
+ --- Helper function to get an array that represents the all modded collectible types.
290
+ --
291
+ -- This function is only useful when building collectible type objects. For most purposes, you
292
+ -- should use the `getModdedCollectibleSet` helper function instead.
293
+ --
294
+ -- Returns an empty array if there are no modded collectible types.
295
+ --
296
+ -- (This function is named differently from the `getVanillaCollectibleTypeRange` function because
297
+ -- all modded collectible types are contiguous. Thus, each value represents a real
298
+ -- `CollectibleType`.)
192
299
  function ____exports.getModdedCollectibleTypes(self)
193
300
  if LAST_VANILLA_COLLECTIBLE_TYPE == LAST_COLLECTIBLE_TYPE then
194
301
  return {}
195
302
  end
196
303
  return irange(nil, FIRST_MODDED_COLLECTIBLE_TYPE, LAST_COLLECTIBLE_TYPE)
197
304
  end
305
+ --- Helper function to get an array that represents the range from the first collectible type to the
306
+ -- last vanilla collectible type. This will include integers that do not represent any valid
307
+ -- collectible types.
308
+ --
309
+ -- This function is only useful when building collectible type objects. For most purposes, you
310
+ -- should use the `getVanillaCollectibleSet` helper function instead.
198
311
  function ____exports.getVanillaCollectibleTypeRange(self)
199
312
  return irange(nil, FIRST_COLLECTIBLE_TYPE, LAST_VANILLA_COLLECTIBLE_TYPE)
200
313
  end
314
+ --- Returns true if the item type in the item config is equal to `ItemType.ITEM_ACTIVE`.
201
315
  function ____exports.isActiveCollectible(self, collectibleType)
202
316
  local itemType = ____exports.getCollectibleItemType(nil, collectibleType)
203
317
  return itemType == ItemType.ACTIVE
204
318
  end
319
+ --- Returns true if the collectible has a red question mark sprite.
205
320
  function ____exports.isBlindCollectible(self, collectible)
206
321
  if not isCollectible(nil, collectible) then
207
322
  local entityID = getEntityID(nil, collectible)
@@ -213,17 +328,28 @@ function ____exports.isBlindCollectible(self, collectible)
213
328
  questionMarkSprite:SetFrame(animation, frame)
214
329
  return ____exports.collectibleSpriteEquals(nil, sprite, questionMarkSprite)
215
330
  end
331
+ --- Returns whether or not the given collectible is a "glitched" item. All items are replaced by
332
+ -- glitched items once a player has TMTRAINER. However, glitched items can also "naturally" appear
333
+ -- in secret rooms and I AM ERROR rooms if the "Corrupted Data" achievement is unlocked.
216
334
  function ____exports.isGlitchedCollectible(self, pickup)
217
335
  return pickup.Variant == PickupVariant.COLLECTIBLE and pickup.SubType > GLITCHED_ITEM_THRESHOLD
218
336
  end
337
+ --- Returns true if the collectible has the "Hidden" attribute in the item config.
338
+ --
339
+ -- Hidden collectibles will not show up in any pools and Eden will not start with them.
219
340
  function ____exports.isHiddenCollectible(self, collectibleType)
220
341
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
221
342
  return itemConfigItem ~= nil and itemConfigItem.Hidden
222
343
  end
344
+ --- Returns true if the item type in the item config is equal to `ItemType.ITEM_PASSIVE` or
345
+ -- `ItemType.ITEM_FAMILIAR`.
223
346
  function ____exports.isPassiveCollectible(self, collectibleType)
224
347
  local itemType = ____exports.getCollectibleItemType(nil, collectibleType)
225
348
  return itemType == ItemType.PASSIVE or itemType == ItemType.FAMILIAR
226
349
  end
350
+ --- Helper function to determine if a particular collectible will disappear from the player's
351
+ -- inventory upon use. Note that this will not work will modded items, as there is no way to
352
+ -- dynamically know if a modded item will disappear.
227
353
  function ____exports.isSingleUseCollectible(self, collectibleType)
228
354
  return SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES_SET:has(collectibleType)
229
355
  end
@@ -231,10 +357,17 @@ function ____exports.isValidCollectibleType(self, collectibleType)
231
357
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
232
358
  return itemConfigItem ~= nil
233
359
  end
360
+ --- Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that it
361
+ -- should remove an item.
362
+ --
363
+ -- The "item tracker" in this function does not refer to the in-game item tracker, but rather to the
364
+ -- Python program located at: https://github.com/Rchardon/RebirthItemTracker
234
365
  function ____exports.removeCollectibleFromItemTracker(self, collectibleType)
235
366
  local collectibleName = ____exports.getCollectibleName(nil, collectibleType)
236
367
  Isaac.DebugString(((("Removing collectible " .. tostring(collectibleType)) .. " (") .. collectibleName) .. ") on player 0 (Player)")
237
368
  end
369
+ --- Helper function to remove all pickup delay on a collectible. By default, collectibles have a 20
370
+ -- frame delay before they can be picked up by a player.
238
371
  function ____exports.removeCollectiblePickupDelay(self, collectible)
239
372
  if not isCollectible(nil, collectible) then
240
373
  local entityID = getEntityID(nil, collectible)
@@ -242,6 +375,8 @@ function ____exports.removeCollectiblePickupDelay(self, collectible)
242
375
  end
243
376
  collectible.Wait = 0
244
377
  end
378
+ --- Helper function to set a collectible sprite to a question mark (i.e. how collectibles look when
379
+ -- the player has Curse of the Blind).
245
380
  function ____exports.setCollectibleBlind(self, collectible)
246
381
  if not isCollectible(nil, collectible) then
247
382
  local entityID = getEntityID(nil, collectible)
@@ -249,6 +384,11 @@ function ____exports.setCollectibleBlind(self, collectible)
249
384
  end
250
385
  ____exports.setCollectibleSprite(nil, collectible, BLIND_ITEM_PNG_PATH)
251
386
  end
387
+ --- Helper function to remove the collectible from a collectible pedestal and make it appear as if a
388
+ -- player has already taken the item. This is accomplished by changing the sub-type to
389
+ -- `CollectibleType.NULL` and then setting the sprite to an empty/missing PNG file.
390
+ --
391
+ -- For more information, see the documentation for the "clearSprite" helper function.
252
392
  function ____exports.setCollectibleEmpty(self, collectible)
253
393
  if not isCollectible(nil, collectible) then
254
394
  local entityID = getEntityID(nil, collectible)
@@ -257,6 +397,8 @@ function ____exports.setCollectibleEmpty(self, collectible)
257
397
  collectible.SubType = CollectibleType.NULL
258
398
  ____exports.clearCollectibleSprite(nil, collectible)
259
399
  end
400
+ --- Helper function to change the collectible on a pedestal. Simply updating the `SubType` property
401
+ -- is not sufficient because the sprite will not change.
260
402
  function ____exports.setCollectibleSubType(self, collectible, newCollectibleType)
261
403
  if not isCollectible(nil, collectible) then
262
404
  local entityID = getEntityID(nil, collectible)
@@ -275,6 +417,8 @@ function ____exports.setCollectibleSubType(self, collectible, newCollectibleType
275
417
  true
276
418
  )
277
419
  end
420
+ --- Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that
421
+ -- the build has been rerolled.
278
422
  function ____exports.setCollectiblesRerolledForItemTracker(self)
279
423
  Isaac.DebugString("Added 3 Collectibles")
280
424
  end
@@ -13,6 +13,9 @@ local getNumbersFromTable = ____table.getNumbersFromTable
13
13
  local tableHasKeys = ____table.tableHasKeys
14
14
  local ____utils = require("functions.utils")
15
15
  local ensureAllCases = ____utils.ensureAllCases
16
+ --- Helper function to check if something is an instantiated Color object.
17
+ --
18
+ -- @category color
16
19
  function ____exports.isColor(self, object)
17
20
  return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
18
21
  end
@@ -26,9 +29,17 @@ local KEYS = {
26
29
  "BO"
27
30
  }
28
31
  OBJECT_NAME = "Color"
32
+ ---
33
+ -- @category color
29
34
  function ____exports.colorEquals(self, color1, color2)
30
35
  return isaacAPIClassEquals(nil, color1, color2, KEYS)
31
36
  end
37
+ --- Helper function to copy a `Color` object.
38
+ --
39
+ -- @param color The Color object to copy. In the case of deserialization, this will actually be a
40
+ -- Lua table instead of an instantiated Color class.
41
+ -- @param serializationType Default is `SerializationType.NONE`.
42
+ -- @category color
32
43
  function ____exports.copyColor(self, color, serializationType)
33
44
  if serializationType == nil then
34
45
  serializationType = SerializationType.NONE
@@ -104,9 +115,16 @@ function ____exports.copyColor(self, color, serializationType)
104
115
  end
105
116
  until true
106
117
  end
118
+ --- Returns `Color(1, 1, 1)`.
119
+ --
120
+ -- @category color
107
121
  function ____exports.getDefaultColor(self)
108
122
  return Color(1, 1, 1)
109
123
  end
124
+ --- Used to determine is the given table is a serialized `Color` object created by the save data
125
+ -- manager and/or the `deepCopy` function.
126
+ --
127
+ -- @category color
110
128
  function ____exports.isSerializedColor(self, object)
111
129
  local objectType = type(object)
112
130
  if objectType ~= "table" then
@@ -1,6 +1,10 @@
1
1
  local ____exports = {}
2
2
  local ____log = require("functions.log")
3
3
  local log = ____log.log
4
+ --- Helper function to get a stack trace.
5
+ --
6
+ -- This will only work if the `--luadebug` launch option is enabled or the Racing+ sandbox is
7
+ -- enabled.
4
8
  function ____exports.getTraceback(self)
5
9
  if debug ~= nil then
6
10
  return debug.traceback()
@@ -10,9 +14,23 @@ function ____exports.getTraceback(self)
10
14
  end
11
15
  return "stack traceback:\n(the \"--luadebug\" flag is not enabled)"
12
16
  end
17
+ --- Players can boot the game with an launch option called "--luadebug", which will enable additional
18
+ -- functionality that is considered to be unsafe. For more information about this flag, see the
19
+ -- wiki: https://bindingofisaacrebirth.fandom.com/wiki/Launch_Options
20
+ --
21
+ -- When this flag is enabled, the global environment will be slightly different. The differences are
22
+ -- documented here: https://wofsauge.github.io/IsaacDocs/rep/Globals.html
23
+ --
24
+ -- This function uses the `package` global variable as a proxy to determine if the "--luadebug" flag
25
+ -- is enabled or not.
13
26
  function ____exports.isLuaDebugEnabled(self)
14
27
  return package ~= nil
15
28
  end
29
+ --- Helper function to print a stack trace to the "log.txt" file, similar to JavaScript's
30
+ -- `console.trace` function.
31
+ --
32
+ -- This will only work if the `--luadebug` launch option is enabled or the Racing+ sandbox is
33
+ -- enabled.
16
34
  function ____exports.traceback(self)
17
35
  local tracebackOutput = ____exports.getTraceback(nil)
18
36
  log(tracebackOutput)