isaacscript-common 1.0.593 → 1.0.594

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.
@@ -5,6 +5,11 @@
5
5
  * combination with the `getHUDOffsetVector()` helper function.
6
6
  */
7
7
  export declare function getHeartsUIWidth(): int;
8
+ /**
9
+ * Returns how many hearts are in the heart UI row. If the player has more than 6 hearts, this
10
+ * function will return 6.
11
+ */
12
+ export declare function getHeartRowLength(player: EntityPlayer): int;
8
13
  /**
9
14
  * In the options menu, players have the ability to set a HUD offset. However, mods do not have
10
15
  * access to this value. To get around this, Mod Config Menu provides a separate HUD offset setting
@@ -1,20 +1,14 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- local getHeartRowLength
4
3
  local ____constants = require("constants")
5
4
  local UI_HEART_WIDTH = ____constants.UI_HEART_WIDTH
6
- function getHeartRowLength(self, player)
7
- local game = Game()
8
- local level = game:GetLevel()
9
- local curses = level:GetCurses()
5
+ function ____exports.getHeartRowLength(self, player)
10
6
  local maxHearts = player:GetMaxHearts()
11
7
  local soulHearts = player:GetSoulHearts()
12
8
  local boneHearts = player:GetBoneHearts()
13
- if curses == LevelCurse.CURSE_OF_THE_UNKNOWN then
14
- return 1
15
- end
16
9
  local combinedHearts = maxHearts + soulHearts + boneHearts * 2
17
- return math.max(combinedHearts / 2, 6)
10
+ local heartRowLength = combinedHearts / 2
11
+ return math.min(heartRowLength, 6)
18
12
  end
19
13
  function ____exports.getScreenBottomRightPos(self)
20
14
  local screenWidth = Isaac.GetScreenWidth()
@@ -22,11 +16,21 @@ function ____exports.getScreenBottomRightPos(self)
22
16
  return Vector(screenWidth, screenHeight)
23
17
  end
24
18
  function ____exports.getHeartsUIWidth(self)
19
+ local game = Game()
20
+ local level = game:GetLevel()
21
+ local curses = level:GetCurses()
25
22
  local player = Isaac.GetPlayer()
26
23
  local extraLives = player:GetExtraLives()
27
24
  local effects = player:GetEffects()
28
25
  local hasHolyMantleEffect = effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_HOLY_MANTLE)
29
- local heartRowLength = getHeartRowLength(nil, player)
26
+ local heartRowLength = ____exports.getHeartRowLength(nil, player)
27
+ if hasHolyMantleEffect then
28
+ heartRowLength = heartRowLength + 1
29
+ end
30
+ if curses == LevelCurse.CURSE_OF_THE_UNKNOWN then
31
+ heartRowLength = 1
32
+ end
33
+ Isaac.DebugString("HEART ROW LENGTH: " .. tostring(heartRowLength))
30
34
  local width = heartRowLength * UI_HEART_WIDTH
31
35
  if extraLives > 9 then
32
36
  width = width + 20
@@ -39,9 +43,6 @@ function ____exports.getHeartsUIWidth(self)
39
43
  width = width + 4
40
44
  end
41
45
  end
42
- if hasHolyMantleEffect then
43
- width = width + UI_HEART_WIDTH
44
- end
45
46
  return width
46
47
  end
47
48
  function ____exports.getHUDOffsetVector(self)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.593",
3
+ "version": "1.0.594",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",