isaacscript-common 4.8.0 → 4.9.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.
|
@@ -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(
|
package/functions/minimap.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { DisplayFlag } from "isaac-typescript-definitions";
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to set the value of `DisplayFlag` for every room on the floor to 0.
|
|
4
|
+
*
|
|
5
|
+
* This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
|
|
6
|
+
* the changes will be immediately visible.
|
|
7
|
+
*/
|
|
8
|
+
export declare function clearFloorDisplayFlags(): void;
|
|
2
9
|
/**
|
|
3
10
|
* Helper function to get the minimap `DisplayFlag` value for every room on the floor. Returns a map
|
|
4
11
|
* that is indexed by the room's safe grid index.
|
package/functions/minimap.lua
CHANGED
|
@@ -3,6 +3,8 @@ local Map = ____lualib.Map
|
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
4
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
5
5
|
local ____exports = {}
|
|
6
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
7
|
+
local DisplayFlagZero = ____isaac_2Dtypescript_2Ddefinitions.DisplayFlagZero
|
|
6
8
|
local ____cachedClasses = require("cachedClasses")
|
|
7
9
|
local game = ____cachedClasses.game
|
|
8
10
|
local ____roomData = require("functions.roomData")
|
|
@@ -18,6 +20,17 @@ function ____exports.setRoomDisplayFlags(self, roomGridIndex, displayFlags)
|
|
|
18
20
|
local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
|
|
19
21
|
roomDescriptor.DisplayFlags = displayFlags
|
|
20
22
|
end
|
|
23
|
+
--- Helper function to set the value of `DisplayFlag` for every room on the floor to 0.
|
|
24
|
+
--
|
|
25
|
+
-- This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
|
|
26
|
+
-- the changes will be immediately visible.
|
|
27
|
+
function ____exports.clearFloorDisplayFlags(self)
|
|
28
|
+
local level = game:GetLevel()
|
|
29
|
+
for ____, room in ipairs(getRoomsInGrid(nil)) do
|
|
30
|
+
room.DisplayFlags = DisplayFlagZero
|
|
31
|
+
end
|
|
32
|
+
level:UpdateVisibility()
|
|
33
|
+
end
|
|
21
34
|
--- Helper function to get the minimap `DisplayFlag` value for every room on the floor. Returns a map
|
|
22
35
|
-- that is indexed by the room's safe grid index.
|
|
23
36
|
function ____exports.getFloorDisplayFlags(self)
|
|
@@ -16,6 +16,12 @@ 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
|
+
*/
|
|
19
25
|
export declare function playerHasHealthLeft(player: EntityPlayer): boolean;
|
|
20
26
|
export declare function removeAllPlayerHealth(player: EntityPlayer): void;
|
|
21
27
|
/**
|
|
@@ -340,10 +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.
|
|
343
347
|
function ____exports.playerHasHealthLeft(self, player)
|
|
344
348
|
local hearts = player:GetHearts()
|
|
345
349
|
local soulHearts = player:GetSoulHearts()
|
|
346
350
|
local boneHearts = player:GetBoneHearts()
|
|
347
|
-
return hearts
|
|
351
|
+
return hearts > 0 or soulHearts > 0 or boneHearts > 0
|
|
348
352
|
end
|
|
349
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.9.0",
|
|
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
|
}
|