isaacscript-common 4.7.3 → 4.8.2
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.
|
@@ -706,7 +706,7 @@ export declare enum ModCallbackCustom {
|
|
|
706
706
|
* what it was on the previous frame.
|
|
707
707
|
*
|
|
708
708
|
* When registering the callback, takes an optional second argument that will make the callback
|
|
709
|
-
* only fire if the
|
|
709
|
+
* only fire if the collectible matches the `CollectibleType` provided.
|
|
710
710
|
*
|
|
711
711
|
* ```ts
|
|
712
712
|
* function postPlayerCollectibleAdded(
|
|
@@ -721,7 +721,7 @@ export declare enum ModCallbackCustom {
|
|
|
721
721
|
* what it was on the previous frame.
|
|
722
722
|
*
|
|
723
723
|
* When registering the callback, takes an optional second argument that will make the callback
|
|
724
|
-
* only fire if the
|
|
724
|
+
* only fire if the collectible matches the `CollectibleType` provided.
|
|
725
725
|
*
|
|
726
726
|
* ```ts
|
|
727
727
|
* function postPlayerCollectibleRemoved(
|
|
@@ -16,6 +16,13 @@ export declare function getPlayerHealthType(player: EntityPlayer, healthType: He
|
|
|
16
16
|
export declare function newPlayerHealth(): PlayerHealth;
|
|
17
17
|
export declare function playerConvertBlackHeartsToSoulHearts(player: EntityPlayer): void;
|
|
18
18
|
export declare function playerConvertSoulHeartsToBlackHearts(player: EntityPlayer): void;
|
|
19
|
+
/**
|
|
20
|
+
* Helper function to see if the player is out of health.
|
|
21
|
+
*
|
|
22
|
+
* Specifically, this function will return false if the player has 0 red hearts, 0 soul/black
|
|
23
|
+
* hearts, and 0 bone hearts.
|
|
24
|
+
*/
|
|
25
|
+
export declare function playerHasHealthLeft(player: EntityPlayer): boolean;
|
|
19
26
|
export declare function removeAllPlayerHealth(player: EntityPlayer): void;
|
|
20
27
|
/**
|
|
21
28
|
* Helper function to set a player's health to a specific state. You can use this in combination
|
|
@@ -340,4 +340,14 @@ function ____exports.playerConvertSoulHeartsToBlackHearts(self, player)
|
|
|
340
340
|
)
|
|
341
341
|
____exports.setPlayerHealth(nil, player, playerHealth)
|
|
342
342
|
end
|
|
343
|
+
--- Helper function to see if the player is out of health.
|
|
344
|
+
--
|
|
345
|
+
-- Specifically, this function will return false if the player has 0 red hearts, 0 soul/black
|
|
346
|
+
-- hearts, and 0 bone hearts.
|
|
347
|
+
function ____exports.playerHasHealthLeft(self, player)
|
|
348
|
+
local hearts = player:GetHearts()
|
|
349
|
+
local soulHearts = player:GetSoulHearts()
|
|
350
|
+
local boneHearts = player:GetBoneHearts()
|
|
351
|
+
return hearts > 0 or soulHearts > 0 or boneHearts > 0
|
|
352
|
+
end
|
|
343
353
|
return ____exports
|
package/functions/random.d.ts
CHANGED
|
@@ -40,5 +40,8 @@ export declare function getRandomFloat(min: int, max: int, seedOrRNG?: Seed | RN
|
|
|
40
40
|
* @param max The upper bound for the random number (inclusive).
|
|
41
41
|
* @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
42
42
|
* `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
43
|
+
* @param exceptions Optional. An array of elements that will be skipped over when getting the
|
|
44
|
+
* random integer. For example, a min of 1, a max of 4, and an exceptions array of
|
|
45
|
+
* `[2]` would cause the function to return either 1, 3, or 4.
|
|
43
46
|
*/
|
|
44
|
-
export declare function getRandomInt(min: int, max: int, seedOrRNG?: Seed | RNG): int;
|
|
47
|
+
export declare function getRandomInt(min: int, max: int, seedOrRNG?: Seed | RNG, exceptions?: int[] | readonly int[]): int;
|
package/functions/random.lua
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Set = ____lualib.Set
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
1
4
|
local ____exports = {}
|
|
2
5
|
local ____rng = require("functions.rng")
|
|
3
6
|
local getRandomSeed = ____rng.getRandomSeed
|
|
@@ -54,10 +57,16 @@ end
|
|
|
54
57
|
-- @param max The upper bound for the random number (inclusive).
|
|
55
58
|
-- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
56
59
|
-- `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
57
|
-
|
|
60
|
+
-- @param exceptions Optional. An array of elements that will be skipped over when getting the
|
|
61
|
+
-- random integer. For example, a min of 1, a max of 4, and an exceptions array of
|
|
62
|
+
-- `[2]` would cause the function to return either 1, 3, or 4.
|
|
63
|
+
function ____exports.getRandomInt(self, min, max, seedOrRNG, exceptions)
|
|
58
64
|
if seedOrRNG == nil then
|
|
59
65
|
seedOrRNG = getRandomSeed(nil)
|
|
60
66
|
end
|
|
67
|
+
if exceptions == nil then
|
|
68
|
+
exceptions = {}
|
|
69
|
+
end
|
|
61
70
|
local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
|
|
62
71
|
if min > max then
|
|
63
72
|
local oldMin = min
|
|
@@ -65,6 +74,13 @@ function ____exports.getRandomInt(self, min, max, seedOrRNG)
|
|
|
65
74
|
min = oldMax
|
|
66
75
|
max = oldMin
|
|
67
76
|
end
|
|
68
|
-
|
|
77
|
+
local exceptionsSet = __TS__New(Set, exceptions)
|
|
78
|
+
local randomInt
|
|
79
|
+
repeat
|
|
80
|
+
do
|
|
81
|
+
randomInt = rng:RandomInt(max - min + 1) + min
|
|
82
|
+
end
|
|
83
|
+
until exceptionsSet:has(randomInt)
|
|
84
|
+
return randomInt
|
|
69
85
|
end
|
|
70
86
|
return ____exports
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.2",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"main": "index",
|
|
23
23
|
"types": "index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"isaac-typescript-definitions": "^3.0.
|
|
25
|
+
"isaac-typescript-definitions": "^3.0.17"
|
|
26
26
|
}
|
|
27
27
|
}
|