isaacscript-common 2.3.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/cachedClasses.lua +24 -0
  2. package/callbacks/customRevive.lua +2 -0
  3. package/callbacks/itemPickup.lua +2 -0
  4. package/callbacks/postBombInitLate.lua +2 -0
  5. package/callbacks/postBoneSwing.lua +2 -0
  6. package/callbacks/postCollectibleInitFirst.lua +2 -0
  7. package/callbacks/postCursedTeleport.lua +2 -0
  8. package/callbacks/postCustomDoorEnter.lua +44 -0
  9. package/callbacks/postDoorRender.lua +2 -0
  10. package/callbacks/postDoorUpdate.lua +2 -0
  11. package/callbacks/postEffectInitLate.lua +2 -0
  12. package/callbacks/postEffectStateChanged.lua +2 -0
  13. package/callbacks/postEsauJr.lua +2 -0
  14. package/callbacks/postFamiliarInitLate.lua +2 -0
  15. package/callbacks/postFamiliarStateChanged.lua +2 -0
  16. package/callbacks/postFlip.lua +2 -0
  17. package/callbacks/postGreedModeWave.lua +2 -0
  18. package/callbacks/postGridEntity.lua +2 -0
  19. package/callbacks/postGridEntityCollision.lua +2 -0
  20. package/callbacks/postGridEntityRender.lua +2 -0
  21. package/callbacks/postHolyMantleRemoved.lua +2 -0
  22. package/callbacks/postKnifeInitLate.lua +2 -0
  23. package/callbacks/postLaserInitLate.lua +2 -0
  24. package/callbacks/postNPCInitLate.lua +2 -0
  25. package/callbacks/postNPCStateChanged.lua +2 -0
  26. package/callbacks/postNewRoomEarly.lua +2 -0
  27. package/callbacks/postPickupCollect.lua +2 -0
  28. package/callbacks/postPickupInitLate.lua +2 -0
  29. package/callbacks/postPickupStateChanged.lua +2 -0
  30. package/callbacks/postPitRender.lua +2 -0
  31. package/callbacks/postPitUpdate.lua +2 -0
  32. package/callbacks/postPlayerChangeHealth.lua +2 -0
  33. package/callbacks/postPlayerChangeType.lua +2 -0
  34. package/callbacks/postPlayerFatalDamage.lua +2 -0
  35. package/callbacks/postPlayerInitLate.lua +2 -0
  36. package/callbacks/postPlayerReordered.lua +2 -0
  37. package/callbacks/postPoopRender.lua +2 -0
  38. package/callbacks/postPoopUpdate.lua +2 -0
  39. package/callbacks/postPressurePlateRender.lua +2 -0
  40. package/callbacks/postPressurePlateUpdate.lua +2 -0
  41. package/callbacks/postProjectileInitLate.lua +2 -0
  42. package/callbacks/postPurchase.lua +2 -0
  43. package/callbacks/postRockRender.lua +2 -0
  44. package/callbacks/postRockUpdate.lua +2 -0
  45. package/callbacks/postRoomClearChanged.lua +2 -0
  46. package/callbacks/postSacrifice.lua +2 -0
  47. package/callbacks/postSlotInitUpdate.lua +2 -0
  48. package/callbacks/postSlotRender.lua +2 -0
  49. package/callbacks/postSpikesRender.lua +2 -0
  50. package/callbacks/postSpikesUpdate.lua +2 -0
  51. package/callbacks/postTNTRender.lua +2 -0
  52. package/callbacks/postTNTUpdate.lua +2 -0
  53. package/callbacks/postTearInitLate.lua +2 -0
  54. package/callbacks/postTearInitVeryLate.lua +2 -0
  55. package/callbacks/postTransformation.lua +2 -0
  56. package/callbacks/postTrinketBreak.lua +2 -0
  57. package/callbacks/preBerserkDeath.lua +2 -0
  58. package/callbacks/preNewLevel.lua +2 -0
  59. package/callbacks/reorderedCallbacks.lua +16 -0
  60. package/callbacks/subscriptions/postBombInitLate.lua +6 -0
  61. package/callbacks/subscriptions/postBoneSwing.lua +6 -0
  62. package/callbacks/subscriptions/postCollectibleInitFirst.lua +6 -0
  63. package/callbacks/subscriptions/postCursedTeleport.lua +6 -0
  64. package/callbacks/subscriptions/postCustomDoorEnter.lua +6 -0
  65. package/callbacks/subscriptions/postCustomRevive.lua +6 -0
  66. package/callbacks/subscriptions/postDoorRender.lua +6 -0
  67. package/callbacks/subscriptions/postDoorUpdate.lua +6 -0
  68. package/callbacks/subscriptions/postEffectInitLate.lua +6 -0
  69. package/callbacks/subscriptions/postEffectStateChanged.lua +6 -0
  70. package/callbacks/subscriptions/postEsauJr.lua +6 -0
  71. package/callbacks/subscriptions/postFamiliarInitLate.lua +6 -0
  72. package/callbacks/subscriptions/postFamiliarStateChanged.lua +6 -0
  73. package/callbacks/subscriptions/postFirstEsauJr.lua +6 -0
  74. package/callbacks/subscriptions/postFirstFlip.lua +6 -0
  75. package/callbacks/subscriptions/postFlip.lua +6 -0
  76. package/callbacks/subscriptions/postGameStartedReordered.lua +6 -0
  77. package/callbacks/subscriptions/postGreedModeWave.lua +6 -0
  78. package/callbacks/subscriptions/postGridEntityBroken.lua +6 -0
  79. package/callbacks/subscriptions/postGridEntityCollision.lua +6 -0
  80. package/callbacks/subscriptions/postGridEntityInit.lua +6 -0
  81. package/callbacks/subscriptions/postGridEntityRemove.lua +6 -0
  82. package/callbacks/subscriptions/postGridEntityRender.lua +6 -0
  83. package/callbacks/subscriptions/postGridEntityStateChanged.lua +6 -0
  84. package/callbacks/subscriptions/postGridEntityUpdate.lua +6 -0
  85. package/callbacks/subscriptions/postHolyMantleRemoved.lua +6 -0
  86. package/callbacks/subscriptions/postItemDischarged.lua +6 -0
  87. package/callbacks/subscriptions/postItemPickup.lua +6 -0
  88. package/callbacks/subscriptions/postKnifeInitLate.lua +6 -0
  89. package/callbacks/subscriptions/postLaserInitLate.lua +6 -0
  90. package/callbacks/subscriptions/postNPCInitLate.lua +6 -0
  91. package/callbacks/subscriptions/postNPCStateChanged.lua +6 -0
  92. package/callbacks/subscriptions/postNewLevelReordered.lua +6 -0
  93. package/callbacks/subscriptions/postNewRoomEarly.lua +6 -0
  94. package/callbacks/subscriptions/postNewRoomReordered.lua +6 -0
  95. package/callbacks/subscriptions/postPEffectUpdateReordered.lua +6 -0
  96. package/callbacks/subscriptions/postPickupCollect.lua +6 -0
  97. package/callbacks/subscriptions/postPickupInitLate.lua +6 -0
  98. package/callbacks/subscriptions/postPickupStateChanged.lua +6 -0
  99. package/callbacks/subscriptions/postPitRender.lua +6 -0
  100. package/callbacks/subscriptions/postPitUpdate.lua +6 -0
  101. package/callbacks/subscriptions/postPlayerChangeHealth.lua +6 -0
  102. package/callbacks/subscriptions/postPlayerChangeType.lua +6 -0
  103. package/callbacks/subscriptions/postPlayerFatalDamage.lua +6 -0
  104. package/callbacks/subscriptions/postPlayerInitLate.lua +6 -0
  105. package/callbacks/subscriptions/postPlayerInitReordered.lua +6 -0
  106. package/callbacks/subscriptions/postPlayerRenderReordered.lua +6 -0
  107. package/callbacks/subscriptions/postPlayerUpdateReordered.lua +6 -0
  108. package/callbacks/subscriptions/postPoopRender.lua +6 -0
  109. package/callbacks/subscriptions/postPoopUpdate.lua +6 -0
  110. package/callbacks/subscriptions/postPressurePlateRender.lua +6 -0
  111. package/callbacks/subscriptions/postPressurePlateUpdate.lua +6 -0
  112. package/callbacks/subscriptions/postProjectileInitLate.lua +6 -0
  113. package/callbacks/subscriptions/postPurchase.lua +6 -0
  114. package/callbacks/subscriptions/postRockRender.lua +6 -0
  115. package/callbacks/subscriptions/postRockUpdate.lua +6 -0
  116. package/callbacks/subscriptions/postRoomClearChanged.lua +6 -0
  117. package/callbacks/subscriptions/postSacrifice.lua +6 -0
  118. package/callbacks/subscriptions/postSlotAnimationChanged.lua +6 -0
  119. package/callbacks/subscriptions/postSlotDestroyed.lua +6 -0
  120. package/callbacks/subscriptions/postSlotInit.lua +6 -0
  121. package/callbacks/subscriptions/postSlotRender.lua +6 -0
  122. package/callbacks/subscriptions/postSlotUpdate.lua +6 -0
  123. package/callbacks/subscriptions/postSpikesRender.lua +6 -0
  124. package/callbacks/subscriptions/postSpikesUpdate.lua +6 -0
  125. package/callbacks/subscriptions/postTNTRender.lua +6 -0
  126. package/callbacks/subscriptions/postTNTUpdate.lua +6 -0
  127. package/callbacks/subscriptions/postTearInitLate.lua +6 -0
  128. package/callbacks/subscriptions/postTearInitVeryLate.lua +6 -0
  129. package/callbacks/subscriptions/postTransformation.lua +6 -0
  130. package/callbacks/subscriptions/postTrinketBreak.lua +6 -0
  131. package/callbacks/subscriptions/preBerserkDeath.lua +6 -0
  132. package/callbacks/subscriptions/preCustomRevive.lua +6 -0
  133. package/callbacks/subscriptions/preItemPickup.lua +6 -0
  134. package/callbacks/subscriptions/preNewLevel.lua +6 -0
  135. package/classes/DefaultMap.d.ts +70 -39
  136. package/classes/DefaultMap.lua +94 -43
  137. package/classes/ModUpgraded.d.ts +3 -3
  138. package/classes/ModUpgraded.lua +5 -0
  139. package/constants.lua +41 -0
  140. package/constantsFirstLast.lua +63 -0
  141. package/enums/HealthType.lua +3 -0
  142. package/enums/ModCallbackCustom.d.ts +1 -1
  143. package/enums/ModCallbackCustom.lua +6 -0
  144. package/enums/private/CopyableIsaacAPIClassType.lua +1 -0
  145. package/enums/private/SerializationBrand.lua +5 -0
  146. package/features/characterHealthConversion.lua +6 -0
  147. package/features/characterStats.lua +17 -0
  148. package/features/debugDisplay/exports.lua +90 -0
  149. package/features/deployJSONRoom.lua +56 -0
  150. package/features/disableInputs.lua +45 -0
  151. package/features/disableSound.lua +14 -0
  152. package/features/extraConsoleCommands/commandsDisplay.lua +90 -0
  153. package/features/extraConsoleCommands/init.lua +16 -0
  154. package/features/extraConsoleCommands/listCommands.lua +172 -0
  155. package/features/fadeInRemover.lua +10 -0
  156. package/features/fastReset.lua +10 -0
  157. package/features/forgottenSwitch.lua +4 -0
  158. package/features/getCollectibleItemPoolType.lua +5 -0
  159. package/features/playerInventory.lua +18 -0
  160. package/features/ponyDetection.lua +4 -0
  161. package/features/preventCollectibleRotation.lua +9 -0
  162. package/features/runInNFrames.lua +50 -0
  163. package/features/saveDataManager/constants.lua +1 -0
  164. package/features/saveDataManager/exports.lua +115 -0
  165. package/features/saveDataManager/main.lua +6 -0
  166. package/features/saveDataManager/maps.lua +3 -0
  167. package/features/saveDataManager/merge.lua +20 -0
  168. package/features/sirenHelpers.lua +13 -0
  169. package/features/taintedLazarusPlayers.lua +11 -0
  170. package/featuresInitialized.lua +6 -0
  171. package/functions/array.lua +85 -0
  172. package/functions/benchmark.lua +6 -0
  173. package/functions/boss.lua +35 -0
  174. package/functions/cacheFlag.lua +4 -0
  175. package/functions/cards.lua +60 -0
  176. package/functions/challenges.lua +1 -0
  177. package/functions/character.lua +23 -0
  178. package/functions/charge.lua +39 -0
  179. package/functions/chargeBar.lua +4 -0
  180. package/functions/collectibleCacheFlag.lua +15 -0
  181. package/functions/collectibleSet.lua +3 -0
  182. package/functions/collectibleTag.lua +9 -0
  183. package/functions/collectibles.lua +131 -0
  184. package/functions/color.lua +18 -0
  185. package/functions/debug.lua +18 -0
  186. package/functions/deepCopy.lua +25 -0
  187. package/functions/doors.lua +53 -0
  188. package/functions/entity.lua +88 -0
  189. package/functions/entitySpecific.lua +182 -0
  190. package/functions/entityTypes.d.ts +1 -1
  191. package/functions/entityTypes.lua +1 -0
  192. package/functions/enums.lua +62 -0
  193. package/functions/familiars.lua +52 -0
  194. package/functions/flag.lua +77 -0
  195. package/functions/flying.lua +10 -0
  196. package/functions/globals.lua +6 -0
  197. package/functions/gridEntity.lua +105 -0
  198. package/functions/gridEntitySpecific.lua +8 -0
  199. package/functions/input.lua +11 -0
  200. package/functions/isaacAPIClass.lua +12 -0
  201. package/functions/jsonHelpers.lua +11 -0
  202. package/functions/jsonRoom.lua +5 -0
  203. package/functions/kColor.lua +9 -0
  204. package/functions/language.lua +5 -0
  205. package/functions/log.lua +28 -0
  206. package/functions/map.lua +18 -0
  207. package/functions/math.lua +26 -0
  208. package/functions/npc.lua +24 -0
  209. package/functions/pickupVariants.d.ts +11 -11
  210. package/functions/pickupVariants.lua +11 -0
  211. package/functions/pickups.lua +67 -0
  212. package/functions/pills.lua +45 -0
  213. package/functions/player.lua +166 -0
  214. package/functions/playerDataStructures.lua +65 -0
  215. package/functions/playerHealth.lua +10 -0
  216. package/functions/playerIndex.lua +47 -0
  217. package/functions/pocketItems.lua +18 -0
  218. package/functions/positionVelocity.lua +46 -0
  219. package/functions/random.lua +32 -0
  220. package/functions/revive.lua +15 -0
  221. package/functions/rng.lua +19 -0
  222. package/functions/roomData.lua +68 -0
  223. package/functions/roomGrid.lua +21 -0
  224. package/functions/roomShape.lua +22 -0
  225. package/functions/rooms.lua +100 -0
  226. package/functions/run.lua +5 -0
  227. package/functions/seeds.lua +4 -0
  228. package/functions/serialization.lua +4 -0
  229. package/functions/set.lua +22 -0
  230. package/functions/spawnCollectible.lua +24 -0
  231. package/functions/sprite.lua +25 -0
  232. package/functions/stage.lua +16 -0
  233. package/functions/string.lua +6 -0
  234. package/functions/table.lua +19 -0
  235. package/functions/tears.lua +12 -0
  236. package/functions/transformations.lua +18 -0
  237. package/functions/trinketCacheFlag.lua +3 -0
  238. package/functions/trinketGive.lua +24 -0
  239. package/functions/trinkets.lua +52 -0
  240. package/functions/tstlClass.lua +9 -0
  241. package/functions/ui.lua +16 -0
  242. package/functions/utils.d.ts +1 -0
  243. package/functions/utils.lua +88 -0
  244. package/functions/vector.lua +9 -0
  245. package/lualib_bundle.lua +21 -34
  246. package/maps/cardMap.lua +1 -0
  247. package/maps/characterMap.lua +1 -0
  248. package/maps/defaultPlayerStatMap.lua +1 -0
  249. package/maps/gridEntityXMLMap.lua +2 -0
  250. package/maps/pillEffectMap.lua +1 -0
  251. package/maps/roomShapeToTopLeftWallGridIndexMap.lua +2 -0
  252. package/maps/roomTypeMap.lua +1 -0
  253. package/objects/LRoomShapeToRectangles.lua +2 -0
  254. package/objects/colors.lua +4 -0
  255. package/objects/roomShapeBounds.lua +2 -0
  256. package/objects/roomShapeLayoutSizes.lua +4 -0
  257. package/objects/roomShapeToBottomRightPosition.lua +2 -0
  258. package/objects/roomShapeToDoorSlotsToGridIndexDelta.lua +2 -0
  259. package/objects/roomShapeToTopLeftPosition.lua +2 -0
  260. package/objects/roomShapeVolumes.lua +3 -0
  261. package/package.json +2 -2
  262. package/patchErrorFunctions.lua +8 -0
  263. package/sets/bossSets.lua +23 -0
  264. package/sets/charactersWithNoRedHeartsSet.lua +2 -0
  265. package/sets/charactersWithNoSoulHeartsSet.lua +2 -0
  266. package/sets/lostStyleCharactersSet.lua +2 -0
  267. package/types/PickingUpItem.lua +7 -0
  268. package/upgradeMod.d.ts +4 -4
  269. package/upgradeMod.lua +18 -0
@@ -6,6 +6,21 @@ local ____array = require("functions.array")
6
6
  local getRandomArrayElement = ____array.getRandomArrayElement
7
7
  local ____rng = require("functions.rng")
8
8
  local getRandomSeed = ____rng.getRandomSeed
9
+ --- TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
10
+ -- when you iterate over them, you will get both the names of the enums and the values of the enums,
11
+ -- in a random order. Use this helper function to get the entries of the enum with the reverse
12
+ -- mappings filtered out.
13
+ --
14
+ -- This function will return the enum values in a sorted order, which may not necessarily be the
15
+ -- same order as which they were declared in.
16
+ --
17
+ -- This function will work properly for both number enums and string enums. (Reverse mappings are
18
+ -- not created for string enums.)
19
+ --
20
+ -- Also see the `getEnumKeys` and `getEnumValues` helper functions.
21
+ --
22
+ -- For a more in depth explanation, see:
23
+ -- https://isaacscript.github.io/gotchas#iterating-over-enums
9
24
  function ____exports.getEnumEntries(self, transpiledEnum)
10
25
  local enumEntries = {}
11
26
  for key, value in pairs(transpiledEnum) do
@@ -27,6 +42,20 @@ function ____exports.getEnumEntries(self, transpiledEnum)
27
42
  )
28
43
  return enumEntries
29
44
  end
45
+ --- TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
46
+ -- when you iterate over them, you will get both the names of the enums and the values of the enums,
47
+ -- in a random order. If all you need are the keys of an enum, use this helper function.
48
+ --
49
+ -- This function will return the enum keys in a sorted order, which may not necessarily be the same
50
+ -- order as which they were declared in.
51
+ --
52
+ -- This function will work properly for both number enums and string enums. (Reverse mappings are
53
+ -- not created for string enums.)
54
+ --
55
+ -- Also see the `getEnumEntries` and `getEnumValues` helper functions.
56
+ --
57
+ -- For a more in depth explanation, see:
58
+ -- https://isaacscript.github.io/gotchas#iterating-over-enums
30
59
  function ____exports.getEnumKeys(self, transpiledEnum)
31
60
  local enumEntries = ____exports.getEnumEntries(nil, transpiledEnum)
32
61
  return __TS__ArrayMap(
@@ -39,10 +68,25 @@ function ____exports.getEnumKeys(self, transpiledEnum)
39
68
  end
40
69
  )
41
70
  end
71
+ --- Helper function to get the amount of entries inside of an enum.
42
72
  function ____exports.getEnumLength(self, transpiledEnum)
43
73
  local enumEntries = ____exports.getEnumEntries(nil, transpiledEnum)
44
74
  return #enumEntries
45
75
  end
76
+ --- TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
77
+ -- when you iterate over them, you will get both the names of the enums and the values of the enums,
78
+ -- in a random order. If all you need are the values of an enum, use this helper function.
79
+ --
80
+ -- This function will return the enum values in a sorted order, which may not necessarily be the
81
+ -- same order as which they were declared in.
82
+ --
83
+ -- This function will work properly for both number enums and string enums. (Reverse mappings are
84
+ -- not created for string enums.)
85
+ --
86
+ -- Also see the `getEnumEntries` and `getEnumKeys` helper functions.
87
+ --
88
+ -- For a more in depth explanation, see:
89
+ -- https://isaacscript.github.io/gotchas#iterating-over-enums
46
90
  function ____exports.getEnumValues(self, transpiledEnum)
47
91
  local enumEntries = ____exports.getEnumEntries(nil, transpiledEnum)
48
92
  return __TS__ArrayMap(
@@ -63,6 +107,12 @@ function ____exports.getLastEnumValue(self, transpiledEnum)
63
107
  end
64
108
  return lastElement
65
109
  end
110
+ --- Helper function to get a random value from the provided enum.
111
+ --
112
+ -- @param transpiledEnum The enum to get the value from.
113
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
114
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`.
115
+ -- @param exceptions Optional. An array of elements to skip over if selected.
66
116
  function ____exports.getRandomEnumValue(self, transpiledEnum, seedOrRNG, exceptions)
67
117
  if seedOrRNG == nil then
68
118
  seedOrRNG = getRandomSeed(nil)
@@ -73,6 +123,18 @@ function ____exports.getRandomEnumValue(self, transpiledEnum, seedOrRNG, excepti
73
123
  local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
74
124
  return getRandomArrayElement(nil, enumValues, seedOrRNG, exceptions)
75
125
  end
126
+ --- Helper function to check every value of a custom enum for -1. This is helpful as a run-time check
127
+ -- because many methods of the Isaac class return -1 if they fail.
128
+ --
129
+ -- For example:
130
+ --
131
+ -- ```ts
132
+ -- enum EntityTypeCustom {
133
+ -- FOO = Isaac.GetEntityTypeByName("Foo"),
134
+ -- }
135
+ --
136
+ -- validateCustomEnum("EntityTypeCustom", EntityTypeCustom);
137
+ -- ```
76
138
  function ____exports.validateCustomEnum(self, transpiledEnumName, transpiledEnum)
77
139
  for ____, ____value in ipairs(____exports.getEnumEntries(nil, transpiledEnum)) do
78
140
  local key = ____value[1]
@@ -3,6 +3,33 @@ local ____cachedClasses = require("cachedClasses")
3
3
  local itemConfig = ____cachedClasses.itemConfig
4
4
  local ____familiarsThatShootPlayerTearsSet = require("sets.familiarsThatShootPlayerTearsSet")
5
5
  local FAMILIARS_THAT_SHOOT_PLAYER_TEARS_SET = ____familiarsThatShootPlayerTearsSet.FAMILIARS_THAT_SHOOT_PLAYER_TEARS_SET
6
+ --- Helper function to add and remove familiars based on a target amount that you specify.
7
+ --
8
+ -- This is a convenience wrapper around the `EntityPlayer.CheckFamiliar` method. Use this helper
9
+ -- function instead so that you do not have to retrieve the `ItemConfigItem` and so that you do not
10
+ -- specify an incorrect RNG object. (The vanilla method is bugged in that it does not increment the
11
+ -- RNG object; see the documentation of the method for more details.)
12
+ --
13
+ -- This function is meant to be called in the EvaluateCache callback (when the cache flag is equal
14
+ -- to `CacheFlag.FAMILIARS`).
15
+ --
16
+ -- Note that this function is only meant to be used in special circumstances where the familiar
17
+ -- count is completely custom and does not correspond to the amount of collectibles. For the general
18
+ -- case, use the `checkFamiliarFromCollectibles` helper function instead.
19
+ --
20
+ -- Note that this will spawn familiars with a completely random `InitSeed`. When calculating random
21
+ -- events for this familiar, you should use a data structure that maps familiar `InitSeed` to RNG
22
+ -- objects that are initialized based on the seed from
23
+ -- `EntityPlayer.GetCollectibleRNG(collectibleType)`.
24
+ --
25
+ -- @param player The player that owns the familiars.
26
+ -- @param collectibleType The collectible type of the collectible associated with this familiar.
27
+ -- @param targetCount The number of familiars that should exist. This function will add or remove
28
+ -- familiars until it matches the target count.
29
+ -- @param familiarVariant The variant of the familiar to spawn or remove.
30
+ -- @param familiarSubType Optional. The sub-type of the familiar to spawn or remove. If not
31
+ -- specified, it will search for existing familiars of all sub-types, and
32
+ -- spawn new familiars with a sub-type of 0.
6
33
  function ____exports.checkFamiliar(self, player, collectibleType, targetCount, familiarVariant, familiarSubType)
7
34
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
8
35
  player:CheckFamiliar(
@@ -13,6 +40,31 @@ function ____exports.checkFamiliar(self, player, collectibleType, targetCount, f
13
40
  familiarSubType
14
41
  )
15
42
  end
43
+ --- Helper function to add and remove familiars based on the amount of associated collectibles that a
44
+ -- player has.
45
+ --
46
+ -- Use this helper function instead of invoking the `EntityPlayer.CheckFamiliar` method directly so
47
+ -- that the target count is handled automatically.
48
+ --
49
+ -- This function is meant to be called in the EvaluateCache callback (when the cache flag is equal
50
+ -- to `CacheFlag.FAMILIARS`).
51
+ --
52
+ -- Use this function when the amount of familiars should be equal to the amount of associated
53
+ -- collectibles that the player has (plus any extras from having used Box of Friends or Monster
54
+ -- Manual). If you instead need to have a custom amount of familiars, use the `checkFamiliars`
55
+ -- function instead.
56
+ --
57
+ -- Note that this will spawn familiars with a completely random `InitSeed`. When calculating random
58
+ -- events for this familiar, you should use a data structure that maps familiar `InitSeed` to RNG
59
+ -- objects that are initialized based on the seed from
60
+ -- `EntityPlayer.GetCollectibleRNG(collectibleType)`.
61
+ --
62
+ -- @param player The player that owns the familiars and collectibles.
63
+ -- @param collectibleType The collectible type of the collectible associated with this familiar.
64
+ -- @param familiarVariant The variant of the familiar to spawn or remove.
65
+ -- @param familiarSubType Optional. The sub-type of the familiar to spawn or remove. If not
66
+ -- specified, it will search for existing familiars of all sub-types, and
67
+ -- spawn new familiars with a sub-type of 0.
16
68
  function ____exports.checkFamiliarFromCollectibles(self, player, collectibleType, familiarVariant, familiarSubType)
17
69
  local numCollectibles = player:GetCollectibleNum(collectibleType)
18
70
  local effects = player:GetEffects()
@@ -1,6 +1,29 @@
1
1
  local ____exports = {}
2
2
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
3
  local DamageFlag = ____isaac_2Dtypescript_2Ddefinitions.DamageFlag
4
+ --- Helper function to add a bit flag to an existing set of bit flags.
5
+ --
6
+ -- This is a variadic function, so pass as many flags as you want to add.
7
+ --
8
+ -- Example 1:
9
+ --
10
+ -- ```ts
11
+ -- // Give the player spectral tears
12
+ -- const player = Isaac.GetPlayer();
13
+ -- player.TearFlags = addFlag(player.TearFlags, TearFlags.TEAR_SPECTRAL);
14
+ -- ```
15
+ --
16
+ -- Example 2:
17
+ --
18
+ -- ```ts
19
+ -- // Give the player spectral and homing tears
20
+ -- const player = Isaac.GetPlayer();
21
+ -- player.TearFlags = addFlag(player.TearFlags, TearFlags.TEAR_SPECTRAL, TearFlags.TEAR_HOMING);
22
+ -- ```
23
+ --
24
+ -- @param flags The existing set of bit flags.
25
+ -- @param flagsToAdd One or more bit flags to add, each as a separate argument.
26
+ -- @returns The combined bit flags.
4
27
  function ____exports.addFlag(self, flags, ...)
5
28
  local flagsToAdd = {...}
6
29
  local flagsAsInt = flags
@@ -9,9 +32,25 @@ function ____exports.addFlag(self, flags, ...)
9
32
  end
10
33
  return flagsAsInt
11
34
  end
35
+ --- Helper function for casting a flag enum value to a `BitFlags` object.
36
+ --
37
+ -- This is useful because the compiler will prevent you from assigning a specific flag to a
38
+ -- `BitFlags` property. (It does this to ensure type safety, since `BitFlags` can represent a zero
39
+ -- value or a composition of N flags.)
40
+ --
41
+ -- For example:
42
+ --
43
+ -- ```ts
44
+ -- player.TearFlags = bitFlags(TearFlag.SPECTRAL);
45
+ -- ```
12
46
  function ____exports.bitFlags(self, flag)
13
47
  return flag
14
48
  end
49
+ --- Helper function to get the key associated with a particular flag.
50
+ --
51
+ -- (Since bit flags are represented by custom objects instead of normal TypeScript enums, you cannot
52
+ -- use the reverse mapping to find the associated key of a given enum value. Use this helper
53
+ -- function instead of indexing the enum directly.)
15
54
  function ____exports.getFlagName(self, flag, flagEnum)
16
55
  for key, value in pairs(flagEnum) do
17
56
  if value == flag then
@@ -20,6 +59,22 @@ function ____exports.getFlagName(self, flag, flagEnum)
20
59
  end
21
60
  return nil
22
61
  end
62
+ --- Helper function to determine if a particular bit flag is set to true.
63
+ --
64
+ -- This is a variadic function, so pass as many flags as you want to check for. If passed multiple
65
+ -- flags, it will only return true if all of the flags are set.
66
+ --
67
+ -- For example:
68
+ --
69
+ -- ```ts
70
+ -- const player = Isaac.GetPlayer();
71
+ -- if (hasFlag(player.TearFlags, TearFlags.TEAR_SPECTRAL) {
72
+ -- // The player currently has spectral tears
73
+ -- }
74
+ -- ```
75
+ --
76
+ -- @param flags The existing set of bit flags.
77
+ -- @param flagsToCheck One or more bit flags to check for, each as a separate argument.
23
78
  function ____exports.hasFlag(self, flags, ...)
24
79
  local flagsToCheck = {...}
25
80
  local flagsAsInt = flags
@@ -30,12 +85,34 @@ function ____exports.hasFlag(self, flags, ...)
30
85
  end
31
86
  return true
32
87
  end
88
+ --- Helper function to check if every bit in the flag is turned off.
89
+ --
90
+ -- (This is equivalent to checking if the flag is equal to 0, but this is not possible without
91
+ -- casting the flag to a number.)
33
92
  function ____exports.isEmptyFlag(self, flag)
34
93
  return flag == 0
35
94
  end
95
+ --- Helper function to determine whether damage to a player in the EntityTakeDmg callback was
96
+ -- self-inflicted. For example, damage from a Curse Room door, a Razor, or a Blood Donation Machine
97
+ -- would count as self-inflicted damage.
36
98
  function ____exports.isSelfDamage(self, damageFlags)
37
99
  return ____exports.hasFlag(nil, damageFlags, DamageFlag.NO_PENALTIES) or ____exports.hasFlag(nil, damageFlags, DamageFlag.RED_HEARTS)
38
100
  end
101
+ --- Helper function to remove a bit flag from an existing set of bit flags.
102
+ --
103
+ -- This is a variadic function, so pass as many flags as you want to remove.
104
+ --
105
+ -- For example:
106
+ --
107
+ -- ```ts
108
+ -- // Remove spectral tears from the player, if present
109
+ -- const player = Isaac.GetPlayer();
110
+ -- player.TearFlags = removeFlag(player.TearFlags, TearFlags.TEAR_SPECTRAL);
111
+ -- ```
112
+ --
113
+ -- @param flags The existing set of bit flags.
114
+ -- @param flagsToRemove One or more bit flags to remove, each as a separate argument.
115
+ -- @returns The combined bit flags.
39
116
  function ____exports.removeFlag(self, flags, ...)
40
117
  local flagsToRemove = {...}
41
118
  local flagsAsInt = flags
@@ -25,6 +25,14 @@ local FLYING_CHARACTERS = __TS__New(Set, {
25
25
  local FLYING_TRINKETS = __TS__New(Set, {TrinketType.BAT_WING, TrinketType.AZAZELS_STUMP})
26
26
  local FLYING_NULL_ITEMS = {NullItemID.REVERSE_SUN, NullItemID.SPIRIT_SHACKLES_SOUL, NullItemID.LOST_CURSE}
27
27
  local CONDITIONAL_FLYING_COLLECTIBLE_TYPES = {CollectibleType.BIBLE, CollectibleType.EMPTY_VESSEL, CollectibleType.ASTRAL_PROJECTION, CollectibleType.RECALL}
28
+ --- Returns a set of all of the collectibles that grant flight. This is derived from collectibles
29
+ -- that have `CacheFlag.FLYING` set in the "items.xml" file.
30
+ --
31
+ -- Collectibles that only grant flight conditionally are manually pruned. Collectibles such as Empty
32
+ -- Vessel should be checked for via the `hasFlyingTemporaryEffect` function.
33
+ --
34
+ -- @param pruneConditionalItems Whether or not collectibles that only grant flight conditionally
35
+ -- should be included in the set (like Empty Vessel).
28
36
  function ____exports.getFlyingCollectibles(self, pruneConditionalItems)
29
37
  local collectiblesWithFlyingCacheFlag = getCollectiblesForCacheFlag(nil, CacheFlag.FLYING)
30
38
  local collectiblesWithAllCacheFlag = getCollectiblesForCacheFlag(nil, CacheFlag.ALL)
@@ -36,6 +44,8 @@ function ____exports.getFlyingCollectibles(self, pruneConditionalItems)
36
44
  end
37
45
  return collectiblesWithFlyingCacheFlag
38
46
  end
47
+ --- Returns a set of all of the trinkets that grant flight. (All trinkets that grant flight do so
48
+ -- conditionally, like Bat Wing.)
39
49
  function ____exports.getFlyingTrinkets(self)
40
50
  return copySet(nil, FLYING_TRINKETS)
41
51
  end
@@ -190,6 +190,10 @@ local DEFAULT_GLOBALS = __TS__New(Set, {
190
190
  })
191
191
  local LUA_DEBUG_ADDED_GLOBALS = __TS__New(Set, {"debug", "io", "os", "package"})
192
192
  local RACING_PLUS_SANDBOX_ADDED_GLOBALS = __TS__New(Set, {"sandboxTraceback", "sandboxGetTraceback", "getParentFunctionDescription"})
193
+ --- Helper function to get a set containing all of the global variable names that are contained
194
+ -- within the Isaac environment by default.
195
+ --
196
+ -- Returns a slightly different set depending on whether the "--luadebug" flag is enabled or not.
193
197
  function ____exports.getDefaultGlobals(self)
194
198
  local defaultGlobals = copySet(nil, DEFAULT_GLOBALS)
195
199
  if isLuaDebugEnabled(nil) then
@@ -198,6 +202,8 @@ function ____exports.getDefaultGlobals(self)
198
202
  addSetsToSet(nil, defaultGlobals, RACING_PLUS_SANDBOX_ADDED_GLOBALS)
199
203
  return defaultGlobals
200
204
  end
205
+ --- Helper function to get an array of any added global variables in the Isaac Lua environment.
206
+ -- Returns an array of key/value tuples.
201
207
  function ____exports.getNewGlobals(self)
202
208
  local defaultGlobals = ____exports.getDefaultGlobals(nil)
203
209
  local newGlobals = {}
@@ -44,12 +44,23 @@ function getAllGridEntities(self)
44
44
  end
45
45
  return gridEntities
46
46
  end
47
+ --- Helper function to get the grid index of the top left wall. (This will depend on what the current
48
+ -- room shape is.)
47
49
  function ____exports.getTopLeftWallGridIndex(self)
48
50
  local room = game:GetRoom()
49
51
  local roomShape = room:GetRoomShape()
50
52
  local topLeftWallGridIndex = ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP:get(roomShape)
51
53
  return topLeftWallGridIndex == nil and DEFAULT_TOP_LEFT_WALL_GRID_INDEX or topLeftWallGridIndex
52
54
  end
55
+ --- Helper function to remove a grid entity simply by providing the grid entity object.
56
+ --
57
+ -- @param gridEntity The grid entity to remove.
58
+ -- @param updateRoom Optional. Whether or not to update the room after the grid entity is removed.
59
+ -- Default is true. This is generally a good idea because if the room is not
60
+ -- updated, you will be unable to spawn another grid entity on the same tile until
61
+ -- a frame has passed. However, doing this is expensive, since it involves a call
62
+ -- to `Isaac.GetRoomEntities`, so set it to false if you need to invoke this
63
+ -- function multiple times.
53
64
  function ____exports.removeGrid(self, gridEntity, updateRoom)
54
65
  if updateRoom == nil then
55
66
  updateRoom = true
@@ -61,6 +72,12 @@ function ____exports.removeGrid(self, gridEntity, updateRoom)
61
72
  roomUpdateSafe(nil)
62
73
  end
63
74
  end
75
+ --- Helper function to spawn a grid entity with a specific variant.
76
+ --
77
+ -- Use this instead of the `Isaac.GridSpawn` method since it:
78
+ -- - handles giving pits collision
79
+ -- - removes existing grid entities on the same tile, if any
80
+ -- - allows you to specify the grid index or the position
64
81
  function ____exports.spawnGridWithVariant(self, gridEntityType, variant, gridIndexOrPosition)
65
82
  local room = game:GetRoom()
66
83
  local ____isVector_result_0
@@ -105,6 +122,9 @@ local BREAKABLE_GRID_ENTITY_TYPES_VARIANTS_BY_EXPLOSIONS = __TS__New(
105
122
  Set,
106
123
  {(tostring(GridEntityType.STATUE) .. ".") .. tostring(StatueVariant.ANGEL)}
107
124
  )
125
+ --- Helper function to convert the grid entity type found in a room XML file to the corresponding
126
+ -- grid entity type and variant normally used by the game. For example, a rock is represented as
127
+ -- 1000.0 in a room XML file, but `GridEntityType.ROCK` is equal to 2.
108
128
  function ____exports.convertXMLGridEntityType(self, gridEntityXMLType, gridEntityXMLVariant)
109
129
  local gridEntityArray = GRID_ENTITY_XML_MAP:get(gridEntityXMLType)
110
130
  if gridEntityArray == nil then
@@ -117,6 +137,11 @@ function ____exports.convertXMLGridEntityType(self, gridEntityXMLType, gridEntit
117
137
  end
118
138
  return {gridEntityType, gridEntityVariant}
119
139
  end
140
+ --- Gets the entities that have a hitbox that overlaps with any part of the square that the grid
141
+ -- entity is on.
142
+ --
143
+ -- Note that this function will not work properly in the PostNewRoom callback, since entities do not
144
+ -- have collision yet in that callback.
120
145
  function ____exports.getCollidingEntitiesWithGridEntity(self, gridEntity)
121
146
  local gridEntityCollisionTopLeft = Vector(gridEntity.Position.X - DISTANCE_OF_GRID_TILE / 2, gridEntity.Position.Y - DISTANCE_OF_GRID_TILE / 2)
122
147
  local gridEntityCollisionBottomRight = Vector(gridEntity.Position.X + DISTANCE_OF_GRID_TILE / 2, gridEntity.Position.Y + DISTANCE_OF_GRID_TILE / 2)
@@ -132,6 +157,28 @@ function ____exports.getCollidingEntitiesWithGridEntity(self, gridEntity)
132
157
  ) end
133
158
  )
134
159
  end
160
+ --- Helper function to get every grid entity in the current room.
161
+ --
162
+ -- Use this function with no arguments to get every grid entity, or specify a variadic amount of
163
+ -- arguments to match specific grid entity types.
164
+ --
165
+ -- For example:
166
+ --
167
+ -- ```ts
168
+ -- for (const gridEntity of getGridEntities()) {
169
+ -- print(gridEntity.GetType())
170
+ -- }
171
+ -- ```
172
+ --
173
+ -- For example:
174
+ --
175
+ -- ```ts
176
+ -- const rocks = getGridEntities(
177
+ -- GridEntityType.ROCK,
178
+ -- GridEntityType.BLOCK,
179
+ -- GridEntityType.ROCK_TINTED,
180
+ -- );
181
+ -- ```
135
182
  function ____exports.getGridEntities(self, ...)
136
183
  local gridEntityTypes = {...}
137
184
  local gridEntities = getAllGridEntities(nil)
@@ -147,6 +194,11 @@ function ____exports.getGridEntities(self, ...)
147
194
  end
148
195
  )
149
196
  end
197
+ --- Helper function to get a map of every grid entity in the current room. The indexes of the map are
198
+ -- equal to the grid index. The values of the map are equal to the grid entities.
199
+ --
200
+ -- Use this function with no arguments to get every grid entity, or specify a variadic amount of
201
+ -- arguments to match specific grid entity types.
150
202
  function ____exports.getGridEntitiesMap(self, ...)
151
203
  local gridEntities = ____exports.getGridEntities(nil, ...)
152
204
  local gridEntityMap = __TS__New(Map)
@@ -156,6 +208,7 @@ function ____exports.getGridEntitiesMap(self, ...)
156
208
  end
157
209
  return gridEntityMap
158
210
  end
211
+ --- Helper function to return a string containing the grid entity's type and variant.
159
212
  function ____exports.getGridEntityID(self, gridEntity)
160
213
  local gridEntityType = gridEntity:GetType()
161
214
  local gridEntityVariant = gridEntity:GetVariant()
@@ -195,15 +248,36 @@ function ____exports.isGridEntityBreakableByExplosion(self, gridEntity)
195
248
  local gridEntityTypeVariant = (tostring(gridEntityType) .. ".") .. tostring(gridEntityVariant)
196
249
  return BREAKABLE_GRID_ENTITY_TYPES_BY_EXPLOSIONS:has(gridEntityType) or BREAKABLE_GRID_ENTITY_TYPES_VARIANTS_BY_EXPLOSIONS:has(gridEntityTypeVariant)
197
250
  end
251
+ --- Helper function to see if the provided gridEntity is in its respective broken state. See the
252
+ -- `GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP` constant for more details.
253
+ --
254
+ -- Note that in the case of `GridEntityType.LOCK` (11), the state will turn to being broken before
255
+ -- the actual collision for the entity is removed.
198
256
  function ____exports.isGridEntityBroken(self, gridEntity)
199
257
  local gridEntityType = gridEntity:GetType()
200
258
  local brokenState = GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP:get(gridEntityType)
201
259
  return gridEntity.State == brokenState
202
260
  end
261
+ --- Helper function to detect whether a given Void Portal is one that randomly spawns after a boss is
262
+ -- defeated or is one that naturally spawns in the room after Hush. (This is determined by looking
263
+ -- at the VarData of the entity.)
203
264
  function ____exports.isPostBossVoidPortal(self, gridEntity)
204
265
  local saveState = gridEntity:GetSaveState()
205
266
  return saveState.VarData == 1
206
267
  end
268
+ --- Helper function to all grid entities in the room except for ones matching the grid entity types
269
+ -- provided.
270
+ --
271
+ -- For example:
272
+ --
273
+ -- ```ts
274
+ -- removeAllGridEntitiesExceptFor(
275
+ -- GridEntityType.WALL,
276
+ -- GridEntityType.DOOR,
277
+ -- );
278
+ -- ```
279
+ --
280
+ -- @returns True if one or more grid entities were removed, false otherwise.
207
281
  function ____exports.removeAllGridExcept(self, ...)
208
282
  local gridEntityTypes = {...}
209
283
  local gridEntityTypeExceptions = __TS__New(Set, gridEntityTypes)
@@ -221,6 +295,20 @@ function ____exports.removeAllGridExcept(self, ...)
221
295
  end
222
296
  return removedOneOrMoreGridEntities
223
297
  end
298
+ --- Helper function to remove all of the grid entities in the room that match the grid entity types
299
+ -- provided.
300
+ --
301
+ -- For example:
302
+ --
303
+ -- ```ts
304
+ -- removeAllMatchingGridEntities(
305
+ -- GridEntityType.ROCK,
306
+ -- GridEntityType.BLOCK,
307
+ -- GridEntityType.ROCK_TINTED,
308
+ -- );
309
+ -- ```
310
+ --
311
+ -- @returns True if one or more grid entities were removed, false otherwise.
224
312
  function ____exports.removeAllMatchingGridEntities(self, ...)
225
313
  local gridEntities = ____exports.getGridEntities(nil, ...)
226
314
  if #gridEntities == 0 then
@@ -232,10 +320,16 @@ function ____exports.removeAllMatchingGridEntities(self, ...)
232
320
  roomUpdateSafe(nil)
233
321
  return true
234
322
  end
323
+ --- Helper function to make a grid entity invisible. This is accomplished by setting its sprite to an
324
+ -- empty/missing PNG file.
325
+ --
326
+ -- For more information, see the documentation for the `clearSprite` helper function.
235
327
  function ____exports.setGridEntityInvisible(self, gridEntity)
236
328
  local sprite = gridEntity:GetSprite()
237
329
  clearSprite(nil, sprite)
238
330
  end
331
+ --- Helper function to spawn a giant poop. This is performed by spawning each of the four quadrant
332
+ -- grid entities in the appropriate positions.
239
333
  function ____exports.spawnGiantPoop(self, topLeftGridIndex)
240
334
  local room = game:GetRoom()
241
335
  local gridWidth = room:GetGridWidth()
@@ -247,9 +341,20 @@ function ____exports.spawnGiantPoop(self, topLeftGridIndex)
247
341
  ____exports.spawnGridWithVariant(nil, GridEntityType.POOP, PoopGridEntityVariant.GIGA_BOTTOM_LEFT, bottomLeftGridIndex)
248
342
  ____exports.spawnGridWithVariant(nil, GridEntityType.POOP, PoopGridEntityVariant.GIGA_BOTTOM_RIGHT, bottomRightGridIndex)
249
343
  end
344
+ --- Helper function to spawn a grid entity.
345
+ --
346
+ -- This function assumes you want to give the grid entity a variant of 0. If you want to specify a
347
+ -- variant, use the `spawnGridWithVariant` helper function instead.
348
+ --
349
+ -- Use this instead of the `Isaac.GridSpawn` method since it:
350
+ -- - handles giving pits collision
351
+ -- - removes existing grid entities on the same tile, if any
352
+ -- - allows you to specify either the grid index or the position
250
353
  function ____exports.spawnGrid(self, gridEntityType, gridIndexOrPosition)
251
354
  return ____exports.spawnGridWithVariant(nil, gridEntityType, 0, gridIndexOrPosition)
252
355
  end
356
+ --- Helper function to spawn a Void Portal. This is more complicated than simply spawning a trapdoor
357
+ -- with the appropriate variant, as the game does not give it the correct sprite automatically.
253
358
  function ____exports.spawnVoidPortal(self, gridIndex)
254
359
  local voidPortal = ____exports.spawnGridWithVariant(nil, GridEntityType.TRAPDOOR, TrapdoorVariant.VOID_PORTAL, gridIndex)
255
360
  if voidPortal == nil then
@@ -7,6 +7,7 @@ local ____cachedClasses = require("cachedClasses")
7
7
  local game = ____cachedClasses.game
8
8
  local ____gridEntity = require("functions.gridEntity")
9
9
  local getGridEntities = ____gridEntity.getGridEntities
10
+ --- Helper function to get all of the `GridEntityPit` in the room.
10
11
  function ____exports.getPits(self)
11
12
  local gridEntities = getGridEntities(nil)
12
13
  local pits = {}
@@ -18,6 +19,7 @@ function ____exports.getPits(self)
18
19
  end
19
20
  return pits
20
21
  end
22
+ --- Helper function to get all of the `GridEntityPoop` in the room.
21
23
  function ____exports.getPoops(self)
22
24
  local gridEntities = getGridEntities(nil)
23
25
  local poops = {}
@@ -29,6 +31,7 @@ function ____exports.getPoops(self)
29
31
  end
30
32
  return poops
31
33
  end
34
+ --- Helper function to get all of the `GridEntityPressurePlate` in the room.
32
35
  function ____exports.getPressurePlates(self)
33
36
  local gridEntities = getGridEntities(nil)
34
37
  local pressurePlates = {}
@@ -40,6 +43,7 @@ function ____exports.getPressurePlates(self)
40
43
  end
41
44
  return pressurePlates
42
45
  end
46
+ --- Helper function to get all of the `GridEntityRock` in the room.
43
47
  function ____exports.getRocks(self)
44
48
  local gridEntities = getGridEntities(nil)
45
49
  local rocks = {}
@@ -51,6 +55,7 @@ function ____exports.getRocks(self)
51
55
  end
52
56
  return rocks
53
57
  end
58
+ --- Helper function to get all of the `GridEntitySpikes` in the room.
54
59
  function ____exports.getSpikes(self)
55
60
  local gridEntities = getGridEntities(nil)
56
61
  local spikes = {}
@@ -62,6 +67,7 @@ function ____exports.getSpikes(self)
62
67
  end
63
68
  return spikes
64
69
  end
70
+ --- Helper function to get all of the `GridEntityTNT` in the room.
65
71
  function ____exports.getTNT(self)
66
72
  local gridEntities = getGridEntities(nil)
67
73
  local tntArray = {}
@@ -73,6 +79,8 @@ function ____exports.getTNT(self)
73
79
  end
74
80
  return tntArray
75
81
  end
82
+ --- Helper function to determine if all of the pressure plates in the current room are pushed.
83
+ -- Returns true if there are no pressure plates in the room.
76
84
  function ____exports.isAllPressurePlatesPushed(self)
77
85
  local room = game:GetRoom()
78
86
  local hasPressurePlates = room:HasTriggerPressurePlates()
@@ -30,6 +30,7 @@ local MOVEMENT_ACTIONS = {ButtonAction.LEFT, ButtonAction.RIGHT, ButtonAction.UP
30
30
  local MOVEMENT_ACTIONS_SET = __TS__New(Set, MOVEMENT_ACTIONS)
31
31
  local SHOOTING_ACTIONS = {ButtonAction.SHOOT_LEFT, ButtonAction.SHOOT_RIGHT, ButtonAction.SHOOT_UP, ButtonAction.SHOOT_DOWN}
32
32
  local SHOOTING_ACTIONS_SET = __TS__New(Set, SHOOTING_ACTIONS)
33
+ --- Helper function to get the enum name for the specified `Controller` value.
33
34
  function ____exports.controllerToString(self, controller)
34
35
  local key = Controller[controller]
35
36
  if key == nil then
@@ -43,6 +44,7 @@ end
43
44
  function ____exports.getShootActions(self)
44
45
  return copySet(nil, SHOOTING_ACTIONS_SET)
45
46
  end
47
+ --- Iterates over all inputs to determine if a particular button is pressed (i.e. held down).
46
48
  function ____exports.isActionPressedOnAnyInput(self, buttonAction)
47
49
  local validInputs = erange(nil, MAX_NUM_INPUTS)
48
50
  return __TS__ArraySome(
@@ -50,6 +52,8 @@ function ____exports.isActionPressedOnAnyInput(self, buttonAction)
50
52
  function(____, input) return Input.IsActionPressed(buttonAction, input) end
51
53
  )
52
54
  end
55
+ --- Iterates over all inputs to determine if a particular button is triggered (i.e. held down and
56
+ -- then released).
53
57
  function ____exports.isActionTriggeredOnAnyInput(self, buttonAction)
54
58
  local validInputs = erange(nil, MAX_NUM_INPUTS)
55
59
  return __TS__ArraySome(
@@ -57,6 +61,10 @@ function ____exports.isActionTriggeredOnAnyInput(self, buttonAction)
57
61
  function(____, input) return Input.IsActionTriggered(buttonAction, input) end
58
62
  )
59
63
  end
64
+ --- Helper function to see if a particular keyboard key is being pressed down by the player.
65
+ --
66
+ -- This function is variadic, meaning you can pass as many keyboard values as you want to check for.
67
+ -- This function will return true if any of the values are pressed.
60
68
  function ____exports.isKeyboardPressed(self, ...)
61
69
  local keys = {...}
62
70
  return __TS__ArraySome(
@@ -64,6 +72,9 @@ function ____exports.isKeyboardPressed(self, ...)
64
72
  function(____, key) return Input.IsButtonPressed(key, ControllerIndex.KEYBOARD) end
65
73
  )
66
74
  end
75
+ --- Helper function to check if one or more modifier keys are being pressed down on the keyboard.
76
+ --
77
+ -- A modifier key is defined as shift, control, alt, or Windows.
67
78
  function ____exports.isModifierKeyPressed(self)
68
79
  return ____exports.isKeyboardPressed(
69
80
  nil,
@@ -1,6 +1,13 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
3
3
  local ____exports = {}
4
+ --- Helper function to get the type of a class from the Isaac API. This is contained within the
5
+ -- "__type" metatable key. In this context, the type of the class is equivalent to the name.
6
+ --
7
+ -- For example, a `Vector` class is has a type of "Vector".
8
+ --
9
+ -- Returns undefined if the object is not of type `userdata` or if the "__type" metatable key does
10
+ -- not exist.
4
11
  function ____exports.getIsaacAPIClassType(self, object)
5
12
  local objectType = type(object)
6
13
  if objectType ~= "userdata" then
@@ -16,6 +23,9 @@ function ____exports.getIsaacAPIClassType(self, object)
16
23
  end
17
24
  return classType
18
25
  end
26
+ --- Helper function to check if something is an instantiated class from the Isaac API. (All classes
27
+ -- from the Isaac API have a type of "userdata" in Lua with a metatable key of "__type" equal to the
28
+ -- name of the class.)
19
29
  function ____exports.isIsaacAPIClass(self, object)
20
30
  local isaacAPIClassType = ____exports.getIsaacAPIClassType(nil, object)
21
31
  return isaacAPIClassType ~= nil
@@ -24,6 +34,8 @@ function ____exports.isIsaacAPIClassOfType(self, object, classType)
24
34
  local isaacAPIClassType = ____exports.getIsaacAPIClassType(nil, object)
25
35
  return isaacAPIClassType == classType or isaacAPIClassType == "const " .. classType
26
36
  end
37
+ --- Helper function to check if an instantiated Isaac API class is equal to another one of the same
38
+ -- type. You must provide the list of keys to check for.
27
39
  function ____exports.isaacAPIClassEquals(self, object1, object2, keys)
28
40
  local table1 = object1
29
41
  local table2 = object2