isaacscript-common 2.3.1 → 3.1.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 (327) 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/postPickupInitLate.lua +2 -0
  30. package/callbacks/postPickupStateChanged.lua +2 -0
  31. package/callbacks/postPitRender.lua +2 -0
  32. package/callbacks/postPitUpdate.lua +2 -0
  33. package/callbacks/postPlayerChangeHealth.lua +2 -0
  34. package/callbacks/postPlayerChangeType.lua +2 -0
  35. package/callbacks/postPlayerFatalDamage.lua +2 -0
  36. package/callbacks/postPlayerInitLate.lua +2 -0
  37. package/callbacks/postPlayerReordered.lua +2 -0
  38. package/callbacks/postPoopRender.lua +2 -0
  39. package/callbacks/postPoopUpdate.lua +2 -0
  40. package/callbacks/postPressurePlateRender.lua +2 -0
  41. package/callbacks/postPressurePlateUpdate.lua +2 -0
  42. package/callbacks/postProjectileInitLate.lua +2 -0
  43. package/callbacks/postPurchase.lua +2 -0
  44. package/callbacks/postRockRender.lua +2 -0
  45. package/callbacks/postRockUpdate.lua +2 -0
  46. package/callbacks/postRoomClearChanged.lua +2 -0
  47. package/callbacks/postSacrifice.lua +2 -0
  48. package/callbacks/postSlotDestroyed.d.ts +1 -0
  49. package/callbacks/postSlotDestroyed.lua +66 -0
  50. package/callbacks/postSlotInitUpdate.lua +2 -0
  51. package/callbacks/postSlotRender.lua +5 -21
  52. package/callbacks/postSpikesRender.lua +2 -0
  53. package/callbacks/postSpikesUpdate.lua +2 -0
  54. package/callbacks/postTNTRender.lua +2 -0
  55. package/callbacks/postTNTUpdate.lua +2 -0
  56. package/callbacks/postTearInitLate.lua +2 -0
  57. package/callbacks/postTearInitVeryLate.lua +2 -0
  58. package/callbacks/postTransformation.lua +2 -0
  59. package/callbacks/postTrinketBreak.lua +2 -0
  60. package/callbacks/preBerserkDeath.lua +2 -0
  61. package/callbacks/preNewLevel.lua +2 -0
  62. package/callbacks/reorderedCallbacks.lua +16 -0
  63. package/callbacks/subscriptions/postBombInitLate.lua +6 -0
  64. package/callbacks/subscriptions/postBoneSwing.lua +6 -0
  65. package/callbacks/subscriptions/postCollectibleInitFirst.lua +6 -0
  66. package/callbacks/subscriptions/postCursedTeleport.lua +6 -0
  67. package/callbacks/subscriptions/postCustomDoorEnter.lua +6 -0
  68. package/callbacks/subscriptions/postCustomRevive.d.ts +1 -0
  69. package/callbacks/subscriptions/postCustomRevive.lua +6 -0
  70. package/callbacks/subscriptions/postDoorRender.d.ts +1 -0
  71. package/callbacks/subscriptions/postDoorRender.lua +6 -0
  72. package/callbacks/subscriptions/postDoorUpdate.d.ts +1 -0
  73. package/callbacks/subscriptions/postDoorUpdate.lua +6 -0
  74. package/callbacks/subscriptions/postEffectInitLate.lua +6 -0
  75. package/callbacks/subscriptions/postEffectStateChanged.lua +6 -0
  76. package/callbacks/subscriptions/postEsauJr.lua +6 -0
  77. package/callbacks/subscriptions/postFamiliarInitLate.lua +6 -0
  78. package/callbacks/subscriptions/postFamiliarStateChanged.lua +6 -0
  79. package/callbacks/subscriptions/postFirstEsauJr.lua +6 -0
  80. package/callbacks/subscriptions/postFirstFlip.lua +6 -0
  81. package/callbacks/subscriptions/postFlip.lua +6 -0
  82. package/callbacks/subscriptions/postGameStartedReordered.lua +6 -0
  83. package/callbacks/subscriptions/postGreedModeWave.lua +6 -0
  84. package/callbacks/subscriptions/postGridEntityBroken.lua +6 -0
  85. package/callbacks/subscriptions/postGridEntityCollision.lua +6 -0
  86. package/callbacks/subscriptions/postGridEntityInit.lua +6 -0
  87. package/callbacks/subscriptions/postGridEntityRemove.lua +6 -0
  88. package/callbacks/subscriptions/postGridEntityRender.lua +6 -0
  89. package/callbacks/subscriptions/postGridEntityStateChanged.lua +6 -0
  90. package/callbacks/subscriptions/postGridEntityUpdate.lua +6 -0
  91. package/callbacks/subscriptions/postHolyMantleRemoved.lua +6 -0
  92. package/callbacks/subscriptions/postItemDischarged.lua +6 -0
  93. package/callbacks/subscriptions/postItemPickup.lua +6 -0
  94. package/callbacks/subscriptions/postKnifeInitLate.lua +6 -0
  95. package/callbacks/subscriptions/postLaserInitLate.lua +6 -0
  96. package/callbacks/subscriptions/postNPCInitLate.lua +6 -0
  97. package/callbacks/subscriptions/postNPCStateChanged.lua +6 -0
  98. package/callbacks/subscriptions/postNewLevelReordered.lua +6 -0
  99. package/callbacks/subscriptions/postNewRoomEarly.lua +6 -0
  100. package/callbacks/subscriptions/postNewRoomReordered.lua +6 -0
  101. package/callbacks/subscriptions/postPEffectUpdateReordered.lua +6 -0
  102. package/callbacks/subscriptions/postPickupCollect.d.ts +1 -0
  103. package/callbacks/subscriptions/postPickupCollect.lua +6 -0
  104. package/callbacks/subscriptions/postPickupInitLate.lua +6 -0
  105. package/callbacks/subscriptions/postPickupStateChanged.d.ts +1 -0
  106. package/callbacks/subscriptions/postPickupStateChanged.lua +6 -0
  107. package/callbacks/subscriptions/postPitRender.d.ts +1 -0
  108. package/callbacks/subscriptions/postPitRender.lua +6 -0
  109. package/callbacks/subscriptions/postPitUpdate.d.ts +1 -0
  110. package/callbacks/subscriptions/postPitUpdate.lua +6 -0
  111. package/callbacks/subscriptions/postPlayerChangeHealth.lua +6 -0
  112. package/callbacks/subscriptions/postPlayerChangeType.lua +6 -0
  113. package/callbacks/subscriptions/postPlayerFatalDamage.lua +6 -0
  114. package/callbacks/subscriptions/postPlayerInitLate.lua +6 -0
  115. package/callbacks/subscriptions/postPlayerInitReordered.lua +6 -0
  116. package/callbacks/subscriptions/postPlayerRenderReordered.lua +6 -0
  117. package/callbacks/subscriptions/postPlayerUpdateReordered.lua +6 -0
  118. package/callbacks/subscriptions/postPoopRender.d.ts +1 -0
  119. package/callbacks/subscriptions/postPoopRender.lua +6 -0
  120. package/callbacks/subscriptions/postPoopUpdate.d.ts +1 -0
  121. package/callbacks/subscriptions/postPoopUpdate.lua +6 -0
  122. package/callbacks/subscriptions/postPressurePlateRender.d.ts +1 -0
  123. package/callbacks/subscriptions/postPressurePlateRender.lua +6 -0
  124. package/callbacks/subscriptions/postPressurePlateUpdate.d.ts +1 -0
  125. package/callbacks/subscriptions/postPressurePlateUpdate.lua +6 -0
  126. package/callbacks/subscriptions/postProjectileInitLate.lua +6 -0
  127. package/callbacks/subscriptions/postPurchase.lua +6 -0
  128. package/callbacks/subscriptions/postRockRender.d.ts +1 -0
  129. package/callbacks/subscriptions/postRockRender.lua +6 -0
  130. package/callbacks/subscriptions/postRockUpdate.d.ts +1 -0
  131. package/callbacks/subscriptions/postRockUpdate.lua +6 -0
  132. package/callbacks/subscriptions/postRoomClearChanged.lua +6 -0
  133. package/callbacks/subscriptions/postSacrifice.lua +6 -0
  134. package/callbacks/subscriptions/postSlotAnimationChanged.lua +6 -0
  135. package/callbacks/subscriptions/postSlotDestroyed.lua +6 -0
  136. package/callbacks/subscriptions/postSlotInit.lua +6 -0
  137. package/callbacks/subscriptions/postSlotRender.lua +6 -0
  138. package/callbacks/subscriptions/postSlotUpdate.lua +6 -0
  139. package/callbacks/subscriptions/postSpikesRender.d.ts +1 -0
  140. package/callbacks/subscriptions/postSpikesRender.lua +6 -0
  141. package/callbacks/subscriptions/postSpikesUpdate.d.ts +1 -0
  142. package/callbacks/subscriptions/postSpikesUpdate.lua +6 -0
  143. package/callbacks/subscriptions/postTNTRender.d.ts +1 -0
  144. package/callbacks/subscriptions/postTNTRender.lua +6 -0
  145. package/callbacks/subscriptions/postTNTUpdate.d.ts +1 -0
  146. package/callbacks/subscriptions/postTNTUpdate.lua +6 -0
  147. package/callbacks/subscriptions/postTearInitLate.lua +6 -0
  148. package/callbacks/subscriptions/postTearInitVeryLate.lua +6 -0
  149. package/callbacks/subscriptions/postTransformation.lua +6 -0
  150. package/callbacks/subscriptions/postTrinketBreak.lua +6 -0
  151. package/callbacks/subscriptions/preBerserkDeath.lua +6 -0
  152. package/callbacks/subscriptions/preCustomRevive.lua +6 -0
  153. package/callbacks/subscriptions/preItemPickup.lua +6 -0
  154. package/callbacks/subscriptions/preNewLevel.lua +6 -0
  155. package/classes/DefaultMap.d.ts +70 -39
  156. package/classes/DefaultMap.lua +94 -43
  157. package/classes/ModUpgraded.d.ts +3 -3
  158. package/classes/ModUpgraded.lua +5 -0
  159. package/constants.lua +41 -0
  160. package/constantsFirstLast.lua +63 -0
  161. package/enums/HealthType.lua +3 -0
  162. package/enums/ModCallbackCustom.d.ts +1 -1
  163. package/enums/ModCallbackCustom.lua +6 -0
  164. package/enums/private/CopyableIsaacAPIClassType.lua +1 -0
  165. package/enums/private/SerializationBrand.lua +5 -0
  166. package/features/characterHealthConversion.lua +6 -0
  167. package/features/characterStats.lua +17 -0
  168. package/features/debugDisplay/exports.d.ts +17 -0
  169. package/features/debugDisplay/exports.lua +90 -0
  170. package/features/debugDisplay/v.d.ts +17 -0
  171. package/features/deployJSONRoom.d.ts +1 -0
  172. package/features/deployJSONRoom.lua +56 -0
  173. package/features/disableInputs.lua +45 -0
  174. package/features/disableSound.lua +14 -0
  175. package/features/extraConsoleCommands/commandsDisplay.lua +90 -0
  176. package/features/extraConsoleCommands/init.lua +16 -0
  177. package/features/extraConsoleCommands/listCommands.lua +172 -0
  178. package/features/fadeInRemover.lua +10 -0
  179. package/features/fastReset.lua +10 -0
  180. package/features/forgottenSwitch.lua +4 -0
  181. package/features/getCollectibleItemPoolType.lua +5 -0
  182. package/features/playerInventory.lua +18 -0
  183. package/features/ponyDetection.lua +4 -0
  184. package/features/preventCollectibleRotation.lua +9 -0
  185. package/features/runInNFrames.lua +50 -0
  186. package/features/saveDataManager/constants.lua +1 -0
  187. package/features/saveDataManager/exports.lua +115 -0
  188. package/features/saveDataManager/load.lua +12 -8
  189. package/features/saveDataManager/main.lua +16 -3
  190. package/features/saveDataManager/maps.lua +3 -0
  191. package/features/saveDataManager/merge.lua +53 -21
  192. package/features/saveDataManager/save.lua +12 -7
  193. package/features/sirenHelpers.lua +13 -0
  194. package/features/taintedLazarusPlayers.lua +11 -0
  195. package/featuresInitialized.lua +6 -0
  196. package/functions/array.d.ts +2 -0
  197. package/functions/array.lua +85 -0
  198. package/functions/benchmark.lua +6 -0
  199. package/functions/boss.lua +35 -0
  200. package/functions/cacheFlag.lua +4 -0
  201. package/functions/cards.lua +60 -0
  202. package/functions/challenges.lua +1 -0
  203. package/functions/character.lua +23 -0
  204. package/functions/charge.lua +39 -0
  205. package/functions/chargeBar.d.ts +1 -0
  206. package/functions/chargeBar.lua +4 -0
  207. package/functions/collectibleCacheFlag.lua +15 -0
  208. package/functions/collectibleSet.lua +3 -0
  209. package/functions/collectibleTag.lua +9 -0
  210. package/functions/collectibles.d.ts +6 -1
  211. package/functions/collectibles.lua +146 -2
  212. package/functions/color.lua +18 -0
  213. package/functions/debug.lua +18 -0
  214. package/functions/deepCopy.lua +60 -26
  215. package/functions/deepCopyTests.lua +8 -5
  216. package/functions/direction.d.ts +1 -0
  217. package/functions/direction.lua +22 -0
  218. package/functions/doors.d.ts +1 -0
  219. package/functions/doors.lua +58 -0
  220. package/functions/entity.d.ts +4 -4
  221. package/functions/entity.lua +94 -6
  222. package/functions/entitySpecific.d.ts +20 -20
  223. package/functions/entitySpecific.lua +182 -0
  224. package/functions/entityTypes.d.ts +1 -1
  225. package/functions/entityTypes.lua +1 -0
  226. package/functions/enums.d.ts +2 -0
  227. package/functions/enums.lua +62 -0
  228. package/functions/familiars.lua +52 -0
  229. package/functions/flag.lua +77 -0
  230. package/functions/flying.lua +10 -0
  231. package/functions/globals.lua +8 -10
  232. package/functions/gridEntity.lua +105 -0
  233. package/functions/gridEntitySpecific.d.ts +5 -0
  234. package/functions/gridEntitySpecific.lua +8 -0
  235. package/functions/input.lua +11 -0
  236. package/functions/isaacAPIClass.d.ts +4 -4
  237. package/functions/isaacAPIClass.lua +15 -3
  238. package/functions/jsonHelpers.lua +11 -0
  239. package/functions/jsonRoom.d.ts +2 -0
  240. package/functions/jsonRoom.lua +5 -0
  241. package/functions/kColor.lua +9 -0
  242. package/functions/language.lua +5 -0
  243. package/functions/log.lua +31 -3
  244. package/functions/map.lua +18 -0
  245. package/functions/math.lua +26 -0
  246. package/functions/npc.lua +24 -0
  247. package/functions/pickupVariants.d.ts +11 -11
  248. package/functions/pickupVariants.lua +11 -0
  249. package/functions/pickups.d.ts +9 -9
  250. package/functions/pickups.lua +67 -0
  251. package/functions/pills.lua +45 -0
  252. package/functions/player.lua +166 -0
  253. package/functions/playerDataStructures.lua +65 -0
  254. package/functions/playerHealth.d.ts +1 -0
  255. package/functions/playerHealth.lua +10 -0
  256. package/functions/playerIndex.d.ts +2 -0
  257. package/functions/playerIndex.lua +47 -0
  258. package/functions/pocketItems.lua +18 -0
  259. package/functions/positionVelocity.d.ts +3 -0
  260. package/functions/positionVelocity.lua +46 -0
  261. package/functions/random.d.ts +2 -0
  262. package/functions/random.lua +32 -0
  263. package/functions/revive.d.ts +2 -0
  264. package/functions/revive.lua +15 -0
  265. package/functions/rng.d.ts +1 -0
  266. package/functions/rng.lua +19 -0
  267. package/functions/roomData.lua +68 -0
  268. package/functions/roomGrid.lua +21 -0
  269. package/functions/roomShape.lua +22 -0
  270. package/functions/rooms.lua +100 -0
  271. package/functions/run.lua +5 -0
  272. package/functions/seeds.lua +4 -0
  273. package/functions/serialization.lua +6 -2
  274. package/functions/set.d.ts +1 -0
  275. package/functions/set.lua +22 -0
  276. package/functions/spawnCollectible.lua +24 -0
  277. package/functions/sprite.d.ts +2 -0
  278. package/functions/sprite.lua +25 -0
  279. package/functions/stage.lua +16 -0
  280. package/functions/string.lua +6 -0
  281. package/functions/table.d.ts +12 -0
  282. package/functions/table.lua +53 -0
  283. package/functions/tears.d.ts +1 -0
  284. package/functions/tears.lua +12 -0
  285. package/functions/transformations.lua +18 -0
  286. package/functions/trinketCacheFlag.lua +3 -0
  287. package/functions/trinketGive.lua +24 -0
  288. package/functions/trinkets.lua +52 -0
  289. package/functions/tstlClass.d.ts +34 -0
  290. package/functions/tstlClass.lua +63 -9
  291. package/functions/ui.d.ts +2 -0
  292. package/functions/ui.lua +16 -0
  293. package/functions/utils.d.ts +16 -0
  294. package/functions/utils.lua +108 -0
  295. package/functions/vector.lua +13 -16
  296. package/index.d.ts +1 -0
  297. package/initCustomCallbacks.lua +3 -0
  298. package/interfaces/ChargeBarSprites.d.ts +1 -0
  299. package/interfaces/private/TSTLClassMetatable.d.ts +2 -0
  300. package/lualib_bundle.lua +21 -34
  301. package/maps/cardMap.lua +1 -0
  302. package/maps/characterMap.lua +1 -0
  303. package/maps/defaultPlayerStatMap.lua +1 -0
  304. package/maps/gridEntityXMLMap.lua +2 -0
  305. package/maps/pillEffectMap.lua +1 -0
  306. package/maps/roomShapeToTopLeftWallGridIndexMap.lua +2 -0
  307. package/maps/roomTypeMap.lua +1 -0
  308. package/objects/LRoomShapeToRectangles.lua +2 -0
  309. package/objects/colors.lua +4 -0
  310. package/objects/oppositeDoorSlots.d.ts +4 -0
  311. package/objects/oppositeDoorSlots.lua +15 -0
  312. package/objects/roomShapeBounds.lua +2 -0
  313. package/objects/roomShapeLayoutSizes.lua +4 -0
  314. package/objects/roomShapeToBottomRightPosition.lua +2 -0
  315. package/objects/roomShapeToDoorSlotsToGridIndexDelta.lua +2 -0
  316. package/objects/roomShapeToTopLeftPosition.lua +2 -0
  317. package/objects/roomShapeVolumes.lua +3 -0
  318. package/package.json +2 -2
  319. package/patchErrorFunctions.lua +8 -0
  320. package/sets/bossSets.lua +23 -0
  321. package/sets/charactersWithNoRedHeartsSet.lua +2 -0
  322. package/sets/charactersWithNoSoulHeartsSet.lua +2 -0
  323. package/sets/lostStyleCharactersSet.lua +2 -0
  324. package/types/AnyEntity.d.ts +10 -0
  325. package/types/PickingUpItem.lua +7 -0
  326. package/upgradeMod.d.ts +4 -4
  327. package/upgradeMod.lua +18 -0
@@ -1,12 +1,18 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__TypeOf = ____lualib.__TS__TypeOf
3
+ local __TS__ArraySort = ____lualib.__TS__ArraySort
3
4
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
4
5
  local ____exports = {}
6
+ local ____utils = require("functions.utils")
7
+ local twoDimensionalSort = ____utils.twoDimensionalSort
8
+ --- In a Map, you can use the `clear` method to delete every element. However, in a LuaTable, the
9
+ -- `clear` method does not exist. Use this helper function as a drop-in replacement for this.
5
10
  function ____exports.clearTable(self, ____table)
6
11
  for key in pairs(____table) do
7
12
  ____table[key] = nil
8
13
  end
9
14
  end
15
+ --- Helper function to copy specific values from a object to a table.
10
16
  function ____exports.copyValuesToTable(self, object, keys, ____table)
11
17
  local otherTable = object
12
18
  for ____, key in ipairs(keys) do
@@ -14,6 +20,10 @@ function ____exports.copyValuesToTable(self, object, keys, ____table)
14
20
  ____table[key] = value
15
21
  end
16
22
  end
23
+ --- Helper function to safely get boolean values from a Lua table. Will throw an error if the
24
+ -- specific value does not exist on the table.
25
+ --
26
+ -- This function is variadic, meaning that you can specify N arguments to get N values.
17
27
  function ____exports.getBooleansFromTable(self, ____table, objectName, ...)
18
28
  local keys = {...}
19
29
  local booleans = {}
@@ -30,6 +40,10 @@ function ____exports.getBooleansFromTable(self, ____table, objectName, ...)
30
40
  end
31
41
  return booleans
32
42
  end
43
+ --- Helper function to safely get number values from a Lua table. Will throw an error if the specific
44
+ -- value does not exist on the table or if it cannot be converted to a number.
45
+ --
46
+ -- This function is variadic, meaning that you can specify N arguments to get N values.
33
47
  function ____exports.getNumbersFromTable(self, ____table, objectName, ...)
34
48
  local keys = {...}
35
49
  local numbers = {}
@@ -52,6 +66,10 @@ function ____exports.getNumbersFromTable(self, ____table, objectName, ...)
52
66
  end
53
67
  return numbers
54
68
  end
69
+ --- Helper function to safely get string values from a Lua table. Will throw an error if the specific
70
+ -- value does not exist on the table.
71
+ --
72
+ -- This function is variadic, meaning that you can specify N arguments to get N values.
55
73
  function ____exports.getStringsFromTable(self, ____table, objectName, ...)
56
74
  local keys = {...}
57
75
  local strings = {}
@@ -69,6 +87,41 @@ function ____exports.getStringsFromTable(self, ____table, objectName, ...)
69
87
  end
70
88
  return strings
71
89
  end
90
+ --- Helper function to iterate over a table deterministically. This is useful because by default, the
91
+ -- `pairs` function will return the keys of a Lua table in a random order.
92
+ --
93
+ -- This function will sort the table entries based on the value of the key.
94
+ --
95
+ -- @param table The table to iterate over.
96
+ -- @param func The function to run for each iteration.
97
+ -- @param deterministic Optional. Whether to iterate deterministically. True by default. You can
98
+ -- dynamically set to false in situations where you need extra performance.
99
+ function ____exports.iterateTableDeterministically(self, ____table, func, deterministic)
100
+ if deterministic == nil then
101
+ deterministic = true
102
+ end
103
+ if not deterministic then
104
+ for key, value in pairs(____table) do
105
+ func(nil, key, value)
106
+ end
107
+ return
108
+ end
109
+ local entriesArray = {}
110
+ for key, value in pairs(____table) do
111
+ local entry = {key, value}
112
+ entriesArray[#entriesArray + 1] = entry
113
+ end
114
+ __TS__ArraySort(entriesArray, twoDimensionalSort)
115
+ for ____, ____value in ipairs(entriesArray) do
116
+ local key = ____value[1]
117
+ local value = ____value[2]
118
+ func(nil, key, value)
119
+ end
120
+ end
121
+ --- Helper function to check if a Lua table has all of the provided keys.
122
+ --
123
+ -- This function is variadic, meaning that you can specify as many arguments as you want to check
124
+ -- for.
72
125
  function ____exports.tableHasKeys(self, ____table, ...)
73
126
  local keys = {...}
74
127
  return __TS__ArrayEvery(
@@ -1,4 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
2
3
  /**
3
4
  * - Converts the specified amount of tears stat into MaxFireDelay and adds it to the player.
4
5
  * - This function should only be used inside the EvaluateCache callback.
@@ -1,10 +1,22 @@
1
1
  local ____exports = {}
2
+ --- - The `EntityPlayer` object stores a player's tear rate in the `MaxFireDelay` attribute. This is
3
+ -- equivalent to how many tears the player can shoot per frame.
4
+ -- - If you already have a "tears" stat and you want to convert it back to MaxFireDelay, then use
5
+ -- this function.
6
+ -- - In this context, the "tears stat" represents what is shown on the in-game stat UI.
2
7
  function ____exports.getFireDelay(self, tearsStat)
3
8
  return math.max(30 / tearsStat - 1, -0.9999)
4
9
  end
10
+ --- - The `EntityPlayer` object stores a player's tear rate in the `MaxFireDelay` attribute. This is
11
+ -- equivalent to how many tears the player can shoot per frame.
12
+ -- - If you want to convert this to the "tears" stat that is shown on the in-game stat UI, then use
13
+ -- this function.
5
14
  function ____exports.getTearsStat(self, fireDelay)
6
15
  return 30 / (fireDelay + 1)
7
16
  end
17
+ --- - Converts the specified amount of tears stat into MaxFireDelay and adds it to the player.
18
+ -- - This function should only be used inside the EvaluateCache callback.
19
+ -- - In this context, the "tears stat" represents what is shown on the in-game stat UI.
8
20
  function ____exports.addTearsStat(self, player, tearsStat)
9
21
  local existingTearsStat = ____exports.getTearsStat(nil, player.MaxFireDelay)
10
22
  local newTearsStat = existingTearsStat + tearsStat
@@ -36,6 +36,14 @@ local TRANSFORMATION_TO_TAG_MAP = __TS__New(Map, {
36
36
  {PlayerForm.SPIDER_BABY, ItemConfigTag.SPIDER}
37
37
  })
38
38
  local TRANSFORMATIONS_THAT_GRANT_FLYING = __TS__New(Set, {PlayerForm.GUPPY, PlayerForm.BEELZEBUB, PlayerForm.SERAPHIM, PlayerForm.LEVIATHAN})
39
+ --- Helper function to get all of the collectible types in the game that count towards a particular
40
+ -- transformation.
41
+ --
42
+ -- For example, to get all of the collectible types that count towards Guppy:
43
+ --
44
+ -- ```ts
45
+ -- const guppyCollectibleTypes = getCollectibleTypesForTransformation(PlayerForm.GUPPY);
46
+ -- ```
39
47
  function ____exports.getCollectibleTypesForTransformation(self, playerForm)
40
48
  local itemConfigTag = TRANSFORMATION_TO_TAG_MAP:get(playerForm)
41
49
  if itemConfigTag == nil then
@@ -43,6 +51,7 @@ function ____exports.getCollectibleTypesForTransformation(self, playerForm)
43
51
  end
44
52
  return getCollectibleTypesWithTag(nil, itemConfigTag)
45
53
  end
54
+ --- Returns the number of items that a player has towards a particular transformation.
46
55
  function ____exports.getPlayerNumCollectiblesForTransformation(self, player, playerForm)
47
56
  local collectibleTypes = ____exports.getCollectibleTypesForTransformation(nil, playerForm)
48
57
  return getPlayerCollectibleCount(
@@ -51,6 +60,7 @@ function ____exports.getPlayerNumCollectiblesForTransformation(self, player, pla
51
60
  __TS__Spread(collectibleTypes:values())
52
61
  )
53
62
  end
63
+ --- Returns a set of the player's current transformations.
54
64
  function ____exports.getPlayerTransformations(self, player)
55
65
  local transformations = __TS__New(Set)
56
66
  for ____, playerForm in ipairs(getEnumValues(nil, PlayerForm)) do
@@ -60,6 +70,14 @@ function ____exports.getPlayerTransformations(self, player)
60
70
  end
61
71
  return transformations
62
72
  end
73
+ --- Helper function to get a transformation name from a PlayerForm enum.
74
+ --
75
+ -- For example:
76
+ --
77
+ -- ```ts
78
+ -- const transformationName = getTransformationName(PlayerForm.LORD_OF_THE_FLIES);
79
+ -- // transformationName is "Beelzebub"
80
+ -- ```
63
81
  function ____exports.getTransformationName(self, playerForm)
64
82
  local transformationName = TRANSFORMATION_NAMES[playerForm]
65
83
  return transformationName == nil and DEFAULT_TRANSFORMATION_NAME or transformationName
@@ -25,6 +25,7 @@ function initCacheFlagMap(self)
25
25
  CACHE_FLAG_TO_TRINKETS_MAP:set(cacheFlag, trinketsSet)
26
26
  end
27
27
  end
28
+ --- Returns a set containing every trinket type with the given cache flag, including modded trinkets.
28
29
  function ____exports.getTrinketsForCacheFlag(self, cacheFlag)
29
30
  if CACHE_FLAG_TO_TRINKETS_MAP.size == 0 then
30
31
  initCacheFlagMap(nil)
@@ -36,6 +37,8 @@ function ____exports.getTrinketsForCacheFlag(self, cacheFlag)
36
37
  return copySet(nil, trinketsSet)
37
38
  end
38
39
  CACHE_FLAG_TO_TRINKETS_MAP = __TS__New(Map)
40
+ --- Returns a map containing every trinket type that the player has that matches the provided
41
+ -- CacheFlag. The values of the map correspond to the multiplier for that trinket.
39
42
  function ____exports.getPlayerTrinketsForCacheFlag(self, player, cacheFlag)
40
43
  local trinketsForCacheFlag = ____exports.getTrinketsForCacheFlag(nil, cacheFlag)
41
44
  local playerTrinkets = __TS__New(Map)
@@ -9,6 +9,11 @@ local ____trinkets = require("functions.trinkets")
9
9
  local getGoldenTrinketType = ____trinkets.getGoldenTrinketType
10
10
  local ____utils = require("functions.utils")
11
11
  local ____repeat = ____utils["repeat"]
12
+ --- Helper function to temporarily removes a player's held trinkets, if any. This will not remove any
13
+ -- smelted trinkets. Use this in combination with the `giveTrinketsBack` function to take away and
14
+ -- give back trinkets on the same frame.
15
+ --
16
+ -- @returns Undefined if the player does not have any trinkets, or TrinketSituation if they do.
12
17
  function ____exports.temporarilyRemoveTrinkets(self, player)
13
18
  local trinketType1 = player:GetTrinket(TrinketSlot.SLOT_1)
14
19
  local trinketType2 = player:GetTrinket(TrinketSlot.SLOT_2)
@@ -23,6 +28,9 @@ function ____exports.temporarilyRemoveTrinkets(self, player)
23
28
  end
24
29
  return {trinketTypeRemoved = TrinketType.NULL, trinketType1 = trinketType1, trinketType2 = trinketType2, numSmeltedTrinkets = 0}
25
30
  end
31
+ --- Helper function to restore the player's trinkets back to the way they were before the
32
+ -- `temporarilyRemoveTrinket` function was used. It will re-smelt any smelted trinkets that were
33
+ -- removed.
26
34
  function ____exports.giveTrinketsBack(self, player, trinketSituation)
27
35
  if trinketSituation == nil then
28
36
  return
@@ -50,6 +58,14 @@ function ____exports.giveTrinketsBack(self, player, trinketSituation)
50
58
  player:AddTrinket(trinketSituation.trinketType2, false)
51
59
  end
52
60
  end
61
+ --- Helper function to smelt a trinket. Before smelting, this function will automatically remove the
62
+ -- trinkets that the player is holding, if any, and then give them back after the new trinket is
63
+ -- smelted.
64
+ --
65
+ -- @param player The player to smelt the trinkets to.
66
+ -- @param trinketType The trinket type to smelt.
67
+ -- @param numTrinkets Optional. If specified, will smelt the given number of trinkets. Use this to
68
+ -- avoid calling this function multiple times. Default is 1.
53
69
  function ____exports.smeltTrinket(self, player, trinketType, numTrinkets)
54
70
  if numTrinkets == nil then
55
71
  numTrinkets = 1
@@ -65,6 +81,14 @@ function ____exports.smeltTrinket(self, player, trinketType, numTrinkets)
65
81
  )
66
82
  ____exports.giveTrinketsBack(nil, player, trinketSituation)
67
83
  end
84
+ --- Helper function to temporarily remove a specific kind of trinket from the player. Use this in
85
+ -- combination with the `giveTrinketsBack` function to take away and give back a trinket on the same
86
+ -- frame. This function correctly handles multiple trinket slots and ensures that all copies of the
87
+ -- trinket are removed, including smelted trinkets.
88
+ --
89
+ -- Note that one smelted golden trinket is the same as two smelted normal trinkets.
90
+ --
91
+ -- @returns Undefined if the player does not have the trinket, or TrinketSituation if they do.
68
92
  function ____exports.temporarilyRemoveTrinket(self, player, trinketType)
69
93
  if not player:HasTrinket(trinketType) then
70
94
  return nil
@@ -28,17 +28,41 @@ local ____sprite = require("functions.sprite")
28
28
  local clearSprite = ____sprite.clearSprite
29
29
  local ____utils = require("functions.utils")
30
30
  local irange = ____utils.irange
31
+ --- Add this to a `TrinketType` to get the corresponding golden trinket type.
32
+ --
33
+ -- Corresponds to the vanilla `PillColor.TRINKET_GOLDEN_FLAG` value.
34
+ --
35
+ -- 1 << 15
31
36
  local GOLDEN_TRINKET_ADJUSTMENT = 32768
32
37
  local TRINKET_SPRITE_LAYER = 0
38
+ --- Helper function to get the corresponding golden trinket type from a normal trinket type.
39
+ --
40
+ -- For example, passing `TrinketType.SWALLOWED_PENNY` would result in 32769, which is the value that
41
+ -- corresponds to the golden trinket sub-type for Swallowed Penny.
33
42
  function ____exports.getGoldenTrinketType(self, trinketType)
34
43
  return trinketType + GOLDEN_TRINKET_ADJUSTMENT
35
44
  end
45
+ --- Helper function to get an array that represents every modded trinket type.
46
+ --
47
+ -- Returns an empty array if there are no modded trinket types.
36
48
  function ____exports.getModdedTrinketTypes(self)
37
49
  if LAST_VANILLA_TRINKET_TYPE == LAST_TRINKET_TYPE then
38
50
  return {}
39
51
  end
40
52
  return irange(nil, FIRST_MODDED_TRINKET_TYPE, LAST_TRINKET_TYPE)
41
53
  end
54
+ --- Returns the slot number corresponding to where a trinket can be safely inserted.
55
+ --
56
+ -- For example:
57
+ --
58
+ -- ```ts
59
+ -- const player = Isaac.GetPlayer();
60
+ -- const trinketSlot = getOpenTrinketSlotNum(player);
61
+ -- if (trinketSlot !== undefined) {
62
+ -- // They have one or more open trinket slots
63
+ -- player.AddTrinket(TrinketType.SWALLOWED_PENNY);
64
+ -- }
65
+ -- ```
42
66
  function ____exports.getOpenTrinketSlot(self, player)
43
67
  local maxTrinkets = player:GetMaxTrinkets()
44
68
  local trinketType1 = player:GetTrinket(TrinketSlot.SLOT_1)
@@ -54,6 +78,8 @@ function ____exports.getOpenTrinketSlot(self, player)
54
78
  end
55
79
  return error("The player has an unknown number of trinket slots: " .. tostring(maxTrinkets))
56
80
  end
81
+ --- Helper function to get the in-game description for a trinket. Returns "Unknown" if the provided
82
+ -- trinket type was not valid.
57
83
  function ____exports.getTrinketDescription(self, trinketType)
58
84
  local trinketDescription = TRINKET_DESCRIPTION_MAP:get(trinketType)
59
85
  if trinketDescription ~= nil then
@@ -65,6 +91,15 @@ function ____exports.getTrinketDescription(self, trinketType)
65
91
  end
66
92
  return DEFAULT_TRINKET_DESCRIPTION
67
93
  end
94
+ --- Helper function to get the name of a trinket. Returns "Unknown" if the provided trinket type is
95
+ -- not valid.
96
+ --
97
+ -- For example:
98
+ --
99
+ -- ```ts
100
+ -- const trinketType = TrinketType.SWALLOWED_PENNY;
101
+ -- const trinketName = getTrinketName(trinketType); // trinketName is "Swallowed Penny"
102
+ -- ```
68
103
  function ____exports.getTrinketName(self, trinketType)
69
104
  local trinketName = TRINKET_NAME_MAP:get(trinketType)
70
105
  if trinketName ~= nil then
@@ -76,12 +111,19 @@ function ____exports.getTrinketName(self, trinketType)
76
111
  end
77
112
  return DEFAULT_TRINKET_NAME
78
113
  end
114
+ --- Helper function to get an array that contains every trinket type.
79
115
  function ____exports.getTrinketTypes(self)
80
116
  return irange(nil, FIRST_TRINKET_TYPE, LAST_TRINKET_TYPE)
81
117
  end
118
+ --- Helper function to get an array that represents every vanilla trinket type.
82
119
  function ____exports.getVanillaTrinketTypes(self)
83
120
  return irange(nil, FIRST_TRINKET_TYPE, LAST_VANILLA_TRINKET_TYPE)
84
121
  end
122
+ --- Returns whether or not the player can hold an additional trinket, beyond what they are currently
123
+ -- carrying. This takes into account items that modify the max number of trinkets, like Mom's Purse.
124
+ --
125
+ -- If the player is the Tainted Soul, this always returns false, since that character cannot pick up
126
+ -- items. (Only Tainted Forgotten can pick up items.)
85
127
  function ____exports.hasOpenTrinketSlot(self, player)
86
128
  if isCharacter(nil, player, PlayerType.THE_SOUL_B) then
87
129
  return false
@@ -92,6 +134,16 @@ end
92
134
  function ____exports.isGoldenTrinket(self, trinketType)
93
135
  return trinketType > GOLDEN_TRINKET_ADJUSTMENT
94
136
  end
137
+ --- Helper function to change the sprite of a trinket entity.
138
+ --
139
+ -- For more information about removing the trinket sprite, see the documentation for the
140
+ -- "clearSprite" helper function.
141
+ --
142
+ -- @param trinket The trinket whose sprite you want to modify.
143
+ -- @param pngPath Equal to either the spritesheet path to load (e.g.
144
+ -- "gfx/items/trinkets/trinket_001_swallowedpenny.png") or undefined. If undefined,
145
+ -- the sprite will be removed, making it appear like the collectible has already been
146
+ -- taken by the player.
95
147
  function ____exports.setTrinketSprite(self, trinket, pngPath)
96
148
  if not isTrinket(nil, trinket) then
97
149
  local entityID = getEntityID(nil, trinket)
@@ -1,9 +1,43 @@
1
+ /// <reference types="typescript-to-lua/language-extensions" />
2
+ import { DefaultMap } from "../classes/DefaultMap";
1
3
  import { TSTLClass } from "../types/private/TSTLClass";
4
+ /**
5
+ * Helper function to get the name of a TypeScriptToLua class. TSTL classes are Lua tables created
6
+ * with the `__TS__Class` Lua function from the TSTL lualib. Their name is contained within
7
+ * "constructor.name" metatable key.
8
+ *
9
+ * For example, a `Map` class is has a name of "Map".
10
+ *
11
+ * Returns undefined if the object is not a table or if the aforementioned metatable key does not
12
+ * exist.
13
+ */
14
+ export declare function getTSTLClassName(object: unknown): string | undefined;
15
+ /**
16
+ * Helper function to determine if a given object is a TypeScriptToLua `Map`.
17
+ *
18
+ * It is not reliable to use the `instanceof` operator to determine this because each Lua module has
19
+ * their own copies of the entire lualib and thus their own instantiated version of a `Map`.
20
+ */
21
+ export declare function isDefaultMap(object: unknown): object is DefaultMap<AnyNotNil, unknown>;
2
22
  /**
3
23
  * Returns whether or not this is a class that is provided by the `isaacscript-common` library, such
4
24
  * as a `DefaultMap`.
5
25
  */
6
26
  export declare function isIsaacScriptCommonClass(object: unknown): boolean;
27
+ /**
28
+ * Helper function to determine if a given object is a TypeScriptToLua `Map`.
29
+ *
30
+ * It is not reliable to use the `instanceof` operator to determine this because each Lua module has
31
+ * their own copies of the entire lualib and thus their own instantiated version of a `Map`.
32
+ */
33
+ export declare function isTSTLMap(object: unknown): object is Map<AnyNotNil, unknown>;
34
+ /**
35
+ * Helper function to determine if a given object is a TypeScriptToLua `Set`.
36
+ *
37
+ * It is not reliable to use the `instanceof` operator to determine this because each Lua module has
38
+ * their own copies of the entire lualib and thus their own instantiated version of a `Set`.
39
+ */
40
+ export declare function isTSTLSet(object: unknown): object is Set<AnyNotNil>;
7
41
  /** TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys. */
8
42
  export declare function isUserDefinedTSTLClass(object: unknown): object is TSTLClass;
9
43
  /**
@@ -1,16 +1,38 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Set = ____lualib.Set
3
3
  local __TS__New = ____lualib.__TS__New
4
- local __TS__InstanceOf = ____lualib.__TS__InstanceOf
5
- local Map = ____lualib.Map
6
- local WeakMap = ____lualib.WeakMap
7
- local WeakSet = ____lualib.WeakSet
8
4
  local ____exports = {}
9
- local newTSTLClassFromMetatable
10
- local ____DefaultMap = require("classes.DefaultMap")
11
- local DefaultMap = ____DefaultMap.DefaultMap
5
+ local newTSTLClassFromMetatable, VANILLA_TSTL_CLASSES
6
+ --- Helper function to get the name of a TypeScriptToLua class. TSTL classes are Lua tables created
7
+ -- with the `__TS__Class` Lua function from the TSTL lualib. Their name is contained within
8
+ -- "constructor.name" metatable key.
9
+ --
10
+ -- For example, a `Map` class is has a name of "Map".
11
+ --
12
+ -- Returns undefined if the object is not a table or if the aforementioned metatable key does not
13
+ -- exist.
14
+ function ____exports.getTSTLClassName(self, object)
15
+ if type(object) ~= "table" then
16
+ return nil
17
+ end
18
+ local metatable = getmetatable(object)
19
+ if metatable == nil then
20
+ return nil
21
+ end
22
+ local constructor = metatable.constructor
23
+ if constructor == nil then
24
+ return nil
25
+ end
26
+ return constructor.name
27
+ end
28
+ --- Returns whether or not this is a class that is provided as part of the TypeScriptToLua
29
+ -- transpiler, such as a `Map` or a `Set`.
12
30
  function ____exports.isVanillaTSTLClass(self, object)
13
- return __TS__InstanceOf(object, Map) or __TS__InstanceOf(object, Set) or __TS__InstanceOf(object, WeakMap) or __TS__InstanceOf(object, WeakSet)
31
+ local className = ____exports.getTSTLClassName(nil, object)
32
+ if className == nil then
33
+ return false
34
+ end
35
+ return VANILLA_TSTL_CLASSES:has(className)
14
36
  end
15
37
  function newTSTLClassFromMetatable(self, metatable)
16
38
  local newClass = {}
@@ -18,10 +40,38 @@ function newTSTLClassFromMetatable(self, metatable)
18
40
  newClassMetatable:____constructor()
19
41
  return newClass
20
42
  end
43
+ VANILLA_TSTL_CLASSES = __TS__New(Set, {"Map", "Set", "WeakMap", "WeakSet"})
21
44
  local TSTL_CLASS_METATABLE_KEYS = __TS__New(Set, {"____constructor", "__index", "constructor"})
45
+ --- Helper function to determine if a given object is a TypeScriptToLua `Map`.
46
+ --
47
+ -- It is not reliable to use the `instanceof` operator to determine this because each Lua module has
48
+ -- their own copies of the entire lualib and thus their own instantiated version of a `Map`.
49
+ function ____exports.isDefaultMap(self, object)
50
+ local className = ____exports.getTSTLClassName(nil, object)
51
+ return className == "DefaultMap"
52
+ end
53
+ --- Returns whether or not this is a class that is provided by the `isaacscript-common` library, such
54
+ -- as a `DefaultMap`.
22
55
  function ____exports.isIsaacScriptCommonClass(self, object)
23
- return __TS__InstanceOf(object, DefaultMap)
56
+ return ____exports.isDefaultMap(nil, object)
57
+ end
58
+ --- Helper function to determine if a given object is a TypeScriptToLua `Map`.
59
+ --
60
+ -- It is not reliable to use the `instanceof` operator to determine this because each Lua module has
61
+ -- their own copies of the entire lualib and thus their own instantiated version of a `Map`.
62
+ function ____exports.isTSTLMap(self, object)
63
+ local className = ____exports.getTSTLClassName(nil, object)
64
+ return className == "Map"
65
+ end
66
+ --- Helper function to determine if a given object is a TypeScriptToLua `Set`.
67
+ --
68
+ -- It is not reliable to use the `instanceof` operator to determine this because each Lua module has
69
+ -- their own copies of the entire lualib and thus their own instantiated version of a `Set`.
70
+ function ____exports.isTSTLSet(self, object)
71
+ local className = ____exports.getTSTLClassName(nil, object)
72
+ return className == "Set"
24
73
  end
74
+ --- TypeScriptToLua classes are Lua tables that have a metatable with a certain amount of keys.
25
75
  function ____exports.isUserDefinedTSTLClass(self, object)
26
76
  if ____exports.isVanillaTSTLClass(nil, object) or ____exports.isIsaacScriptCommonClass(nil, object) then
27
77
  return false
@@ -46,6 +96,10 @@ function ____exports.isUserDefinedTSTLClass(self, object)
46
96
  end
47
97
  return numKeys == TSTL_CLASS_METATABLE_KEYS.size
48
98
  end
99
+ --- Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class
100
+ -- it is. This function requires that you provide an instantiated class of the same type, as it will
101
+ -- use the class constructor that is present on the other object's metatable to initialize the new
102
+ -- class.
49
103
  function ____exports.newTSTLClass(self, oldClass)
50
104
  local metatable = getmetatable(oldClass)
51
105
  if metatable == nil then
package/functions/ui.d.ts CHANGED
@@ -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
  /**
3
5
  * In the options menu, players have the ability to set a HUD offset. However, mods do not have
4
6
  * access to this value. To get around this, Mod Config Menu provides a separate HUD offset setting
package/functions/ui.lua CHANGED
@@ -14,6 +14,14 @@ function ____exports.getScreenBottomRightPos(self)
14
14
  local screenHeight = Isaac.GetScreenHeight()
15
15
  return Vector(screenWidth, screenHeight)
16
16
  end
17
+ --- In the options menu, players have the ability to set a HUD offset. However, mods do not have
18
+ -- access to this value. To get around this, Mod Config Menu provides a separate HUD offset setting
19
+ -- on the first page of the menu. This is intended to be set by end-users to match their vanilla HUD
20
+ -- offset setting so that mods can render UI elements to the screen in the correct position.
21
+ --
22
+ -- @returns If the user does not have Mod Config Menu enabled, or does not have this option set,
23
+ -- then this function will return `Vector.Zero.` Otherwise, it will return a Vector that
24
+ -- represents a HUD offset that should be added to the position of a UI element.
17
25
  function ____exports.getHUDOffsetVector(self)
18
26
  local defaultVector = copyVector(nil, VectorZero)
19
27
  local hudOffset = math.floor(Options.HUDOffset * 10)
@@ -30,6 +38,8 @@ function ____exports.getHUDOffsetVector(self)
30
38
  end
31
39
  return Vector(x, y)
32
40
  end
41
+ --- Returns how many hearts are in the heart UI row. If the player has more than 6 hearts, this
42
+ -- function will return 6.
33
43
  function ____exports.getHeartRowLength(self, player)
34
44
  local maxHearts = player:GetMaxHearts()
35
45
  local soulHearts = player:GetSoulHearts()
@@ -38,6 +48,9 @@ function ____exports.getHeartRowLength(self, player)
38
48
  local heartRowLength = combinedHearts / 2
39
49
  return math.min(heartRowLength, 6)
40
50
  end
51
+ --- Helper function to get the width of the first player's hearts on the UI. This is useful for
52
+ -- drawing UI elements to the right of where the player's hearts are. Make sure to use this in
53
+ -- combination with the the `getHUDOffsetVector` helper function.
41
54
  function ____exports.getHeartsUIWidth(self)
42
55
  local level = game:GetLevel()
43
56
  local curses = level:GetCurses()
@@ -81,6 +94,9 @@ function ____exports.getScreenTopRightPos(self)
81
94
  local bottomRight = ____exports.getScreenBottomRightPos(nil)
82
95
  return Vector(bottomRight.X, 0)
83
96
  end
97
+ --- Get how many hearts are currently being shown on the hearts UI.
98
+ --
99
+ -- This function is originally from piber20 Helper.
84
100
  function ____exports.getVisibleHearts(self, player)
85
101
  local effectiveMaxHearts = player:GetEffectiveMaxHearts()
86
102
  local soulHearts = player:GetSoulHearts()
@@ -1,4 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
2
3
  /**
3
4
  * Helper function to get type safety on a switch statement.
4
5
  *
@@ -65,6 +66,7 @@ export declare function hexToKColor(hexString: string, alpha: float): KColor;
65
66
  * If only one argument is specified, then it will assume that the start is 0.
66
67
  */
67
68
  export declare function irange(start: int, end?: int): int[];
69
+ export declare function isPrimitive(variable: unknown): boolean;
68
70
  /**
69
71
  * Since this is a UI element, we do not want to draw it in water reflections. `renderOffset` will
70
72
  * be a non-zero value in reflections.
@@ -110,3 +112,17 @@ export declare function repeat(n: int, func: (i: int) => void): void;
110
112
  * This function does not actually do anything. (It is an "empty" function.)
111
113
  */
112
114
  export declare function todo(): void;
115
+ /**
116
+ * Helper function to sort a two-dimensional array by the first element.
117
+ *
118
+ * For example:
119
+ *
120
+ * ```ts
121
+ * const myArray = [[1, 2], [2, 3], [3, 4]];
122
+ * myArray.sort(twoDimensionalSort);
123
+ * ```
124
+ *
125
+ * From:
126
+ * https://stackoverflow.com/questions/16096872/how-to-sort-2-dimensional-array-by-column-value
127
+ */
128
+ export declare function twoDimensionalSort<T>(a: T[], b: T[]): -1 | 0 | 1;