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
@@ -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
@@ -4,7 +4,6 @@ local __TS__New = ____lualib.__TS__New
4
4
  local __TS__ArraySort = ____lualib.__TS__ArraySort
5
5
  local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
6
6
  local ____exports = {}
7
- local twoDimensionalSort
8
7
  local ____debug = require("functions.debug")
9
8
  local isLuaDebugEnabled = ____debug.isLuaDebugEnabled
10
9
  local ____log = require("functions.log")
@@ -12,15 +11,8 @@ local log = ____log.log
12
11
  local ____set = require("functions.set")
13
12
  local addSetsToSet = ____set.addSetsToSet
14
13
  local copySet = ____set.copySet
15
- function twoDimensionalSort(self, a, b)
16
- if a[1] == nil or b[1] == nil then
17
- error("Failed to two-dimensional sort since the first element of the array was undefined.")
18
- end
19
- if a[1] == b[1] then
20
- return 0
21
- end
22
- return a[1] < b[1] and -1 or 1
23
- end
14
+ local ____utils = require("functions.utils")
15
+ local twoDimensionalSort = ____utils.twoDimensionalSort
24
16
  local DEFAULT_GLOBALS = __TS__New(Set, {
25
17
  "ActionTriggers",
26
18
  "ActiveSlot",
@@ -190,6 +182,10 @@ local DEFAULT_GLOBALS = __TS__New(Set, {
190
182
  })
191
183
  local LUA_DEBUG_ADDED_GLOBALS = __TS__New(Set, {"debug", "io", "os", "package"})
192
184
  local RACING_PLUS_SANDBOX_ADDED_GLOBALS = __TS__New(Set, {"sandboxTraceback", "sandboxGetTraceback", "getParentFunctionDescription"})
185
+ --- Helper function to get a set containing all of the global variable names that are contained
186
+ -- within the Isaac environment by default.
187
+ --
188
+ -- Returns a slightly different set depending on whether the "--luadebug" flag is enabled or not.
193
189
  function ____exports.getDefaultGlobals(self)
194
190
  local defaultGlobals = copySet(nil, DEFAULT_GLOBALS)
195
191
  if isLuaDebugEnabled(nil) then
@@ -198,6 +194,8 @@ function ____exports.getDefaultGlobals(self)
198
194
  addSetsToSet(nil, defaultGlobals, RACING_PLUS_SANDBOX_ADDED_GLOBALS)
199
195
  return defaultGlobals
200
196
  end
197
+ --- Helper function to get an array of any added global variables in the Isaac Lua environment.
198
+ -- Returns an array of key/value tuples.
201
199
  function ____exports.getNewGlobals(self)
202
200
  local defaultGlobals = ____exports.getDefaultGlobals(nil)
203
201
  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
@@ -1,4 +1,9 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
4
+ /// <reference types="isaac-typescript-definitions" />
5
+ /// <reference types="isaac-typescript-definitions" />
6
+ /// <reference types="isaac-typescript-definitions" />
2
7
  /** Helper function to get all of the `GridEntityPit` in the room. */
3
8
  export declare function getPits(): GridEntityPit[];
4
9
  /** Helper function to get all of the `GridEntityPoop` in the room. */
@@ -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,14 +1,14 @@
1
1
  import { IsaacAPIClass } from "../types/private/IsaacAPIClass";
2
2
  /**
3
- * Helper function to get the type of a class from the Isaac API. This is contained within the
4
- * "__type" metatable key. In this context, the type of the class is equivalent to the name.
3
+ * Helper function to get the name of a class from the Isaac API. This is contained within the
4
+ * "__type" metatable key.
5
5
  *
6
- * For example, a `Vector` class is has a type of "Vector".
6
+ * For example, a `Vector` class is has a name of "Vector".
7
7
  *
8
8
  * Returns undefined if the object is not of type `userdata` or if the "__type" metatable key does
9
9
  * not exist.
10
10
  */
11
- export declare function getIsaacAPIClassType(object: unknown): string | undefined;
11
+ export declare function getIsaacAPIClassName(object: unknown): string | undefined;
12
12
  /**
13
13
  * Helper function to check if something is an instantiated class from the Isaac API. (All classes
14
14
  * from the Isaac API have a type of "userdata" in Lua with a metatable key of "__type" equal to the
@@ -1,7 +1,14 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
3
3
  local ____exports = {}
4
- function ____exports.getIsaacAPIClassType(self, object)
4
+ --- Helper function to get the name of a class from the Isaac API. This is contained within the
5
+ -- "__type" metatable key.
6
+ --
7
+ -- For example, a `Vector` class is has a name of "Vector".
8
+ --
9
+ -- Returns undefined if the object is not of type `userdata` or if the "__type" metatable key does
10
+ -- not exist.
11
+ function ____exports.getIsaacAPIClassName(self, object)
5
12
  local objectType = type(object)
6
13
  if objectType ~= "userdata" then
7
14
  return nil
@@ -16,14 +23,19 @@ 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
- local isaacAPIClassType = ____exports.getIsaacAPIClassType(nil, object)
30
+ local isaacAPIClassType = ____exports.getIsaacAPIClassName(nil, object)
21
31
  return isaacAPIClassType ~= nil
22
32
  end
23
33
  function ____exports.isIsaacAPIClassOfType(self, object, classType)
24
- local isaacAPIClassType = ____exports.getIsaacAPIClassType(nil, object)
34
+ local isaacAPIClassType = ____exports.getIsaacAPIClassName(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
@@ -8,6 +8,12 @@ end
8
8
  local function tryEncode(____table)
9
9
  return json.encode(____table)
10
10
  end
11
+ --- Converts a JSON string to a Lua table.
12
+ --
13
+ -- In most cases, this function will be used for reading data from a "save#.dat" file. If decoding
14
+ -- fails, it will return a blank Lua table instead of throwing an error. (This allows execution to
15
+ -- continue in cases where users have no current save data or have manually removed their existing
16
+ -- save data.)
11
17
  function ____exports.jsonDecode(self, jsonString)
12
18
  local ok, luaTableOrErrMsg = pcall(tryDecode, jsonString)
13
19
  if not ok then
@@ -16,6 +22,11 @@ function ____exports.jsonDecode(self, jsonString)
16
22
  end
17
23
  return luaTableOrErrMsg
18
24
  end
25
+ --- Converts a Lua table to a JSON string.
26
+ --
27
+ -- In most cases, this function will be used for writing data to a "save#.dat" file. If encoding
28
+ -- fails, it will throw an error to prevent writing a blank string or corrupted data to a user's
29
+ -- "save#.dat" file.
19
30
  function ____exports.jsonEncode(self, ____table)
20
31
  local ok, jsonStringOrErrMsg = pcall(tryEncode, ____table)
21
32
  if not ok then
@@ -1,4 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
2
4
  import { JSONRoom } from "../interfaces/JSONRoom";
3
5
  export declare function getJSONRoomOfVariant(jsonRooms: JSONRoom[], variant: int): JSONRoom | undefined;
4
6
  export declare function getJSONRoomsOfSubType(jsonRooms: JSONRoom[], subType: int): JSONRoom[];
@@ -66,6 +66,11 @@ function ____exports.getJSONRoomsOfSubType(self, jsonRooms, subType)
66
66
  end
67
67
  )
68
68
  end
69
+ --- Helper function to get a random JSON room from an array of JSON rooms.
70
+ --
71
+ -- Note that this function does not simply choose a random element in the provided array; it will
72
+ -- properly account for each room weight using the algorithm from:
73
+ -- https://stackoverflow.com/questions/1761626/weighted-random-numbers
69
74
  function ____exports.getRandomJSONRoom(self, jsonRooms, seedOrRNG, verbose)
70
75
  if seedOrRNG == nil then
71
76
  seedOrRNG = getRandomSeed(nil)
@@ -13,11 +13,17 @@ 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 KColor object.
16
17
  function ____exports.isKColor(self, object)
17
18
  return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
18
19
  end
19
20
  local KEYS = {"Red", "Green", "Blue", "Alpha"}
20
21
  OBJECT_NAME = "KColor"
22
+ --- Helper function to copy a `KColor` object.
23
+ --
24
+ -- @param kColor The KColor object to copy. In the case of deserialization, this will actually be a
25
+ -- Lua table instead of an instantiated KColor class.
26
+ -- @param serializationType Default is `SerializationType.NONE`.
21
27
  function ____exports.copyKColor(self, kColor, serializationType)
22
28
  if serializationType == nil then
23
29
  serializationType = SerializationType.NONE
@@ -80,9 +86,12 @@ function ____exports.copyKColor(self, kColor, serializationType)
80
86
  end
81
87
  until true
82
88
  end
89
+ --- Returns `KColor(1, 1, 1, 1)`.
83
90
  function ____exports.getDefaultKColor(self)
84
91
  return KColor(1, 1, 1, 1)
85
92
  end
93
+ --- Used to determine is the given table is a serialized `KColor` object created by the save data
94
+ -- manager and/or the `deepCopy` function.
86
95
  function ____exports.isSerializedKColor(self, object)
87
96
  local objectType = type(object)
88
97
  if objectType ~= "table" then
@@ -1,6 +1,11 @@
1
1
  local ____exports = {}
2
2
  local ____languageNames = require("objects.languageNames")
3
3
  local LANGUAGE_NAMES = ____languageNames.LANGUAGE_NAMES
4
+ --- Helper function to convert the language abbreviation from `Options.Language` to the "full"
5
+ -- language name.
6
+ --
7
+ -- For example, if the current language is set to Korean, `Options.Language` will be set to "kr",
8
+ -- and this function will return "Korean".
4
9
  function ____exports.getLanguageName(self)
5
10
  local languageAbbreviation = Options.Language
6
11
  return LANGUAGE_NAMES[languageAbbreviation]