isaacscript-common 4.8.1 → 4.9.1
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.
- package/enums/ModCallbackCustom.d.ts +2 -2
- package/functions/array.d.ts +2 -2
- package/functions/array.lua +5 -3
- package/functions/minimap.d.ts +7 -0
- package/functions/minimap.lua +13 -0
- package/functions/random.d.ts +4 -1
- package/functions/random.lua +18 -2
- package/functions/set.d.ts +4 -1
- package/functions/set.lua +5 -2
- package/objects/oppositeDoorSlots.lua +1 -1
- package/package.json +2 -2
|
@@ -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/array.d.ts
CHANGED
|
@@ -63,7 +63,6 @@ export declare function emptyArray<T>(array: T[]): void;
|
|
|
63
63
|
* For example, if this function is provided an array containing 1, 2, and 3, then it will return an
|
|
64
64
|
* array containing the following arrays:
|
|
65
65
|
*
|
|
66
|
-
* - []
|
|
67
66
|
* - [1]
|
|
68
67
|
* - [2]
|
|
69
68
|
* - [3]
|
|
@@ -75,11 +74,12 @@ export declare function emptyArray<T>(array: T[]): void;
|
|
|
75
74
|
* From: https://github.com/firstandthird/combinations/blob/master/index.js
|
|
76
75
|
*
|
|
77
76
|
* @param array The array to get the combinations of.
|
|
77
|
+
* @param includeEmptyArray Whether or not to include an empty array in the combinations.
|
|
78
78
|
* @param min Optional. The minimum number of elements to include in each combination. Default is 1.
|
|
79
79
|
* @param max Optional. The maximum number of elements to include in each combination. Default is
|
|
80
80
|
* the length of the array.
|
|
81
81
|
*/
|
|
82
|
-
export declare function getArrayCombinations<T>(array: T[] | readonly T[], min?: int, max?: int): ReadonlyArray<readonly T[]>;
|
|
82
|
+
export declare function getArrayCombinations<T>(array: T[] | readonly T[], includeEmptyArray: boolean, min?: int, max?: int): ReadonlyArray<readonly T[]>;
|
|
83
83
|
/**
|
|
84
84
|
* Helper function to get an array containing the indexes of an array.
|
|
85
85
|
*
|
package/functions/array.lua
CHANGED
|
@@ -214,7 +214,6 @@ end
|
|
|
214
214
|
-- For example, if this function is provided an array containing 1, 2, and 3, then it will return an
|
|
215
215
|
-- array containing the following arrays:
|
|
216
216
|
--
|
|
217
|
-
-- - []
|
|
218
217
|
-- - [1]
|
|
219
218
|
-- - [2]
|
|
220
219
|
-- - [3]
|
|
@@ -226,10 +225,11 @@ end
|
|
|
226
225
|
-- From: https://github.com/firstandthird/combinations/blob/master/index.js
|
|
227
226
|
--
|
|
228
227
|
-- @param array The array to get the combinations of.
|
|
228
|
+
-- @param includeEmptyArray Whether or not to include an empty array in the combinations.
|
|
229
229
|
-- @param min Optional. The minimum number of elements to include in each combination. Default is 1.
|
|
230
230
|
-- @param max Optional. The maximum number of elements to include in each combination. Default is
|
|
231
231
|
-- the length of the array.
|
|
232
|
-
function ____exports.getArrayCombinations(self, array, min, max)
|
|
232
|
+
function ____exports.getArrayCombinations(self, array, includeEmptyArray, min, max)
|
|
233
233
|
if min == nil or min <= 0 then
|
|
234
234
|
min = 1
|
|
235
235
|
end
|
|
@@ -276,7 +276,9 @@ function ____exports.getArrayCombinations(self, array, min, max)
|
|
|
276
276
|
if #array == max then
|
|
277
277
|
all[#all + 1] = array
|
|
278
278
|
end
|
|
279
|
-
|
|
279
|
+
if includeEmptyArray then
|
|
280
|
+
__TS__ArrayUnshift(all, {})
|
|
281
|
+
end
|
|
280
282
|
return all
|
|
281
283
|
end
|
|
282
284
|
--- Helper function to get an array containing the indexes of an array.
|
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)
|
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/functions/set.d.ts
CHANGED
|
@@ -46,8 +46,11 @@ export declare function getRandomSetElement<T>(set: Set<T> | ReadonlySet<T>, see
|
|
|
46
46
|
* - [1, 3]
|
|
47
47
|
* - [2, 3]
|
|
48
48
|
* - [1, 2, 3]
|
|
49
|
+
*
|
|
50
|
+
* @param set The set to get the combinations of.
|
|
51
|
+
* @param includeEmptyArray Whether or not to include an empty array in the combinations.
|
|
49
52
|
*/
|
|
50
|
-
export declare function getSetCombinations<T>(set: Set<T> | ReadonlySet<T
|
|
53
|
+
export declare function getSetCombinations<T>(set: Set<T> | ReadonlySet<T>, includeEmptyArray: boolean): ReadonlyArray<ReadonlySet<T>>;
|
|
51
54
|
/**
|
|
52
55
|
* Helper function to get a sorted array based on the contents of a set.
|
|
53
56
|
*
|
package/functions/set.lua
CHANGED
|
@@ -96,9 +96,12 @@ end
|
|
|
96
96
|
-- - [1, 3]
|
|
97
97
|
-- - [2, 3]
|
|
98
98
|
-- - [1, 2, 3]
|
|
99
|
-
|
|
99
|
+
--
|
|
100
|
+
-- @param set The set to get the combinations of.
|
|
101
|
+
-- @param includeEmptyArray Whether or not to include an empty array in the combinations.
|
|
102
|
+
function ____exports.getSetCombinations(self, set, includeEmptyArray)
|
|
100
103
|
local values = ____exports.getSortedSetValues(nil, set)
|
|
101
|
-
local combinations = getArrayCombinations(nil, values)
|
|
104
|
+
local combinations = getArrayCombinations(nil, values, includeEmptyArray)
|
|
102
105
|
return __TS__ArrayMap(
|
|
103
106
|
combinations,
|
|
104
107
|
function(____, array) return __TS__New(Set, array) end
|
|
@@ -6,8 +6,8 @@ ____exports.OPPOSITE_DOOR_SLOTS = {
|
|
|
6
6
|
[DoorSlot.LEFT_0] = DoorSlot.RIGHT_0,
|
|
7
7
|
[DoorSlot.UP_0] = DoorSlot.DOWN_0,
|
|
8
8
|
[DoorSlot.RIGHT_0] = DoorSlot.LEFT_0,
|
|
9
|
-
[DoorSlot.LEFT_1] = DoorSlot.RIGHT_1,
|
|
10
9
|
[DoorSlot.DOWN_0] = DoorSlot.UP_0,
|
|
10
|
+
[DoorSlot.LEFT_1] = DoorSlot.RIGHT_1,
|
|
11
11
|
[DoorSlot.UP_1] = DoorSlot.DOWN_1,
|
|
12
12
|
[DoorSlot.RIGHT_1] = DoorSlot.LEFT_1,
|
|
13
13
|
[DoorSlot.DOWN_1] = DoorSlot.UP_1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.1",
|
|
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
|
}
|