isaacscript-common 1.0.344 → 1.0.348

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.
@@ -45,16 +45,16 @@ function getCurrentHealthValue(self, player, healthType)
45
45
  return player:GetHearts()
46
46
  end
47
47
  end
48
- ____cond10 = ____cond10 or (____switch10 == HealthType.ROTTEN)
48
+ ____cond10 = ____cond10 or (____switch10 == HealthType.SOUL)
49
49
  if ____cond10 then
50
50
  do
51
- return player:GetRottenHearts()
51
+ return player:GetSoulHearts()
52
52
  end
53
53
  end
54
- ____cond10 = ____cond10 or (____switch10 == HealthType.SOUL)
54
+ ____cond10 = ____cond10 or (____switch10 == HealthType.ETERNAL)
55
55
  if ____cond10 then
56
56
  do
57
- return player:GetSoulHearts()
57
+ return player:GetEternalHearts()
58
58
  end
59
59
  end
60
60
  ____cond10 = ____cond10 or (____switch10 == HealthType.BLACK)
@@ -63,22 +63,22 @@ function getCurrentHealthValue(self, player, healthType)
63
63
  return player:GetBlackHearts()
64
64
  end
65
65
  end
66
- ____cond10 = ____cond10 or (____switch10 == HealthType.BONE)
66
+ ____cond10 = ____cond10 or (____switch10 == HealthType.GOLDEN)
67
67
  if ____cond10 then
68
68
  do
69
- return player:GetBoneHearts()
69
+ return player:GetGoldenHearts()
70
70
  end
71
71
  end
72
- ____cond10 = ____cond10 or (____switch10 == HealthType.GOLDEN)
72
+ ____cond10 = ____cond10 or (____switch10 == HealthType.BONE)
73
73
  if ____cond10 then
74
74
  do
75
- return player:GetGoldenHearts()
75
+ return player:GetBoneHearts()
76
76
  end
77
77
  end
78
- ____cond10 = ____cond10 or (____switch10 == HealthType.ETERNAL)
78
+ ____cond10 = ____cond10 or (____switch10 == HealthType.ROTTEN)
79
79
  if ____cond10 then
80
80
  do
81
- return player:GetEternalHearts()
81
+ return player:GetRottenHearts()
82
82
  end
83
83
  end
84
84
  ____cond10 = ____cond10 or (____switch10 == HealthType.MAX_HEARTS)
@@ -1,7 +1,22 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  export declare function getAngleDifference(angle1: float, angle2: float): float;
3
+ /**
4
+ * Helper function to get an array of equidistant points on the circumference around a circle.
5
+ * Useful for equally distributing things in a circle pattern.
6
+ *
7
+ * @param centerPos A position that represents the center of the center to get the points from.
8
+ * @param radius The radius of the circle.
9
+ * @param numPoints The number of points on the circumference of the circle to get.
10
+ * @param xMultiplier An optional multiplier to get the points around an oval. Default is 1.
11
+ * @param yMultiplier An optional multiplier to get the points around an oval. Default is 1.
12
+ * @param initialDirection By default, the first point on the circle will be on the top center, but
13
+ * this can be optionally changed by specifying this argument.
14
+ */
15
+ export declare function getCircleDiscretizedPoints(centerPos: Vector, radius: float, numPoints: int, xMultiplier?: number, yMultiplier?: number, initialDirection?: Direction): Vector[];
3
16
  export declare function isEven(num: int): boolean;
4
17
  export declare function isOdd(num: int): boolean;
18
+ export declare function lerp(a: number, b: number, pos: float): number;
19
+ export declare function lerpAngleDegrees(aStart: number, aEnd: number, percent: float): number;
5
20
  /**
6
21
  * If rounding fails, this function returns 0.
7
22
  * From: http://lua-users.org/wiki/SimpleRound
@@ -1,15 +1,91 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ require("lualib_bundle");
2
3
  local ____exports = {}
4
+ local ____util = require("functions.util")
5
+ local ensureAllCases = ____util.ensureAllCases
6
+ local getCircleInitialPosition
7
+ function getCircleInitialPosition(self, direction, radius)
8
+ repeat
9
+ local ____switch6 = direction
10
+ local ____cond6 = ____switch6 == Direction.NO_DIRECTION
11
+ if ____cond6 then
12
+ do
13
+ return Vector.Zero
14
+ end
15
+ end
16
+ ____cond6 = ____cond6 or (____switch6 == Direction.LEFT)
17
+ if ____cond6 then
18
+ do
19
+ return Vector(-radius, 0)
20
+ end
21
+ end
22
+ ____cond6 = ____cond6 or (____switch6 == Direction.UP)
23
+ if ____cond6 then
24
+ do
25
+ return Vector(0, -radius)
26
+ end
27
+ end
28
+ ____cond6 = ____cond6 or (____switch6 == Direction.RIGHT)
29
+ if ____cond6 then
30
+ do
31
+ return Vector(radius, 0)
32
+ end
33
+ end
34
+ ____cond6 = ____cond6 or (____switch6 == Direction.DOWN)
35
+ if ____cond6 then
36
+ do
37
+ return Vector(0, radius)
38
+ end
39
+ end
40
+ do
41
+ do
42
+ ensureAllCases(nil, direction)
43
+ return Vector.Zero
44
+ end
45
+ end
46
+ until true
47
+ end
3
48
  function ____exports.getAngleDifference(self, angle1, angle2)
4
49
  local subtractedAngle = angle1 - angle2
5
50
  return ((subtractedAngle + 180) % 360) - 180
6
51
  end
52
+ function ____exports.getCircleDiscretizedPoints(self, centerPos, radius, numPoints, xMultiplier, yMultiplier, initialDirection)
53
+ if xMultiplier == nil then
54
+ xMultiplier = 1
55
+ end
56
+ if yMultiplier == nil then
57
+ yMultiplier = 1
58
+ end
59
+ if initialDirection == nil then
60
+ initialDirection = Direction.UP
61
+ end
62
+ local initialPosition = getCircleInitialPosition(nil, initialDirection, radius)
63
+ local positions = {}
64
+ do
65
+ local i = 0
66
+ while i < numPoints do
67
+ local rotatedPosition = initialPosition:Rotated((i * 360) / numPoints)
68
+ rotatedPosition.X = rotatedPosition.X * xMultiplier
69
+ rotatedPosition.Y = rotatedPosition.Y * yMultiplier
70
+ local positionFromCenter = centerPos + rotatedPosition
71
+ __TS__ArrayPush(positions, positionFromCenter)
72
+ i = i + 1
73
+ end
74
+ end
75
+ return positions
76
+ end
7
77
  function ____exports.isEven(self, num)
8
78
  return (num & 1) == 0
9
79
  end
10
80
  function ____exports.isOdd(self, num)
11
81
  return (num & 1) == 1
12
82
  end
83
+ function ____exports.lerp(self, a, b, pos)
84
+ return a + ((b - a) * pos)
85
+ end
86
+ function ____exports.lerpAngleDegrees(self, aStart, aEnd, percent)
87
+ return aStart + (____exports.getAngleDifference(nil, aStart, aEnd) * percent)
88
+ end
13
89
  function ____exports.round(self, num, numDecimalPlaces)
14
90
  if numDecimalPlaces == nil then
15
91
  numDecimalPlaces = 0
@@ -138,10 +138,10 @@ function ____exports.getLastHeart(self, player)
138
138
  end
139
139
  return HealthType.RED
140
140
  end
141
- local numBits = getNumBitsOfN(nil, blackHearts)
142
- local finalBit = getKBitOfN(nil, numBits - 1, blackHearts)
143
- local isBlack = finalBit == 1
144
141
  if soulHearts > 0 then
142
+ local numBits = getNumBitsOfN(nil, blackHearts)
143
+ local finalBit = getKBitOfN(nil, numBits - 1, blackHearts)
144
+ local isBlack = finalBit == 1
145
145
  if isBlack then
146
146
  return HealthType.BLACK
147
147
  end
@@ -63,8 +63,6 @@ export declare function isGreedMode(): boolean;
63
63
  */
64
64
  export declare function isSerializedVector(object: unknown): boolean;
65
65
  export declare function isVector(object: unknown): boolean;
66
- export declare function lerp(a: number, b: number, pos: float): number;
67
- export declare function lerpAngleDegrees(aStart: number, aEnd: number, percent: float): number;
68
66
  /**
69
67
  * Whether or not the player is playing on a set seed (i.e. that they entered in a specific seed by
70
68
  * pressing tab on the character selection screen). When the player resets the game on a set seed,
@@ -3,8 +3,6 @@ require("lualib_bundle");
3
3
  local ____exports = {}
4
4
  local ____constants = require("constants")
5
5
  local VECTOR_BRAND = ____constants.VECTOR_BRAND
6
- local ____math = require("functions.math")
7
- local getAngleDifference = ____math.getAngleDifference
8
6
  local HEX_STRING_LENGTH = 6
9
7
  function ____exports.copySet(self, oldSet)
10
8
  local newSet = __TS__New(Set)
@@ -75,12 +73,6 @@ function ____exports.isVector(self, object)
75
73
  local vectorMetatable = metatable
76
74
  return vectorMetatable.__type == "Vector"
77
75
  end
78
- function ____exports.lerp(self, a, b, pos)
79
- return a + ((b - a) * pos)
80
- end
81
- function ____exports.lerpAngleDegrees(self, aStart, aEnd, percent)
82
- return aStart + (getAngleDifference(nil, aStart, aEnd) * percent)
83
- end
84
76
  function ____exports.onSetSeed(self)
85
77
  local game = Game()
86
78
  local seeds = game:GetSeeds()
@@ -71,8 +71,11 @@ ____exports.default = (function()
71
71
  local debugMsg = getDebugPrependString(nil, callbackName)
72
72
  local function callbackWithLogger(____, ...)
73
73
  Isaac.DebugString(debugMsg .. " - START")
74
- callback(nil, ...)
75
- Isaac.DebugString(debugMsg .. " - END")
74
+ local value = callback(nil, ...)
75
+ Isaac.DebugString(
76
+ (debugMsg .. " - END - ") .. tostring(value)
77
+ )
78
+ return value
76
79
  end
77
80
  self.Mod:AddCallback(callbackID, callbackWithLogger, optionalArg)
78
81
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.344",
3
+ "version": "1.0.348",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,10 +25,10 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "devDependencies": {
28
- "isaac-typescript-definitions": "^1.0.212",
28
+ "isaac-typescript-definitions": "^1.0.230",
29
29
  "isaacscript-lint": "^1.0.63",
30
30
  "typedoc": "^0.22.5",
31
- "typescript": "4.4.3",
31
+ "typescript": "4.4.4",
32
32
  "typescript-to-lua": "^1.0.1"
33
33
  }
34
34
  }