isaacscript-common 1.2.200 → 1.2.203
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/dist/callbacks/customRevive.lua +6 -11
- package/dist/callbacks/postNewRoomEarly.lua +3 -5
- package/dist/classes/ModUpgraded.d.ts +1 -3
- package/dist/classes/ModUpgraded.lua +2 -36
- package/dist/constants.d.ts +4 -0
- package/dist/constants.lua +2 -0
- package/dist/enums/private/SerializationBrand.d.ts +2 -0
- package/dist/enums/private/SerializationBrand.lua +2 -0
- package/dist/features/deployJSONRoom.d.ts +6 -12
- package/dist/features/deployJSONRoom.lua +17 -18
- package/dist/features/saveDataManager/load.lua +2 -1
- package/dist/features/saveDataManager/main.lua +3 -3
- package/dist/features/saveDataManager/merge.d.ts +12 -3
- package/dist/features/saveDataManager/merge.lua +16 -11
- package/dist/functions/array.d.ts +7 -7
- package/dist/functions/array.lua +22 -22
- package/dist/functions/cards.d.ts +6 -6
- package/dist/functions/cards.lua +14 -12
- package/dist/functions/color.d.ts +19 -1
- package/dist/functions/color.lua +89 -10
- package/dist/functions/deepCopy.d.ts +8 -12
- package/dist/functions/deepCopy.lua +13 -29
- package/dist/functions/doors.d.ts +4 -0
- package/dist/functions/doors.lua +12 -2
- package/dist/functions/entity.lua +4 -4
- package/dist/functions/jsonHelpers.lua +2 -2
- package/dist/functions/jsonRoom.d.ts +1 -1
- package/dist/functions/jsonRoom.lua +6 -4
- package/dist/functions/log.d.ts +12 -1
- package/dist/functions/log.lua +12 -4
- package/dist/functions/map.d.ts +0 -12
- package/dist/functions/map.lua +0 -23
- package/dist/functions/random.d.ts +27 -27
- package/dist/functions/random.lua +35 -29
- package/dist/functions/revive.lua +7 -0
- package/dist/functions/rng.d.ts +44 -0
- package/dist/functions/rng.lua +106 -0
- package/dist/functions/roomData.d.ts +5 -0
- package/dist/functions/roomData.lua +31 -4
- package/dist/functions/set.d.ts +2 -2
- package/dist/functions/set.lua +6 -4
- package/dist/functions/spawnCollectible.d.ts +3 -3
- package/dist/functions/spawnCollectible.lua +11 -10
- package/dist/functions/table.d.ts +30 -0
- package/dist/functions/table.lua +73 -1
- package/dist/functions/utils.d.ts +5 -0
- package/dist/functions/utils.lua +12 -0
- package/dist/functions/vector.d.ts +23 -3
- package/dist/functions/vector.lua +72 -21
- package/dist/index.d.ts +1 -0
- package/dist/index.lua +8 -0
- package/dist/objects/roomShapeToDoorSlots.d.ts +4 -0
- package/dist/objects/roomShapeToDoorSlots.lua +44 -0
- package/dist/upgradeMod.d.ts +1 -3
- package/dist/upgradeMod.lua +2 -5
- package/package.json +2 -2
|
@@ -3,48 +3,48 @@
|
|
|
3
3
|
* This returns a random float between 0 and 1. It is inclusive on the low end, but exclusive on
|
|
4
4
|
* the high end. (This is because the `RNG.RandomFloat` method can return a value of 0.999, but it
|
|
5
5
|
* will never return a value of exactly 1.)
|
|
6
|
+
*
|
|
7
|
+
* Note that this function will invoke the `Next` method on the `RNG` object before returning the
|
|
8
|
+
* random number.
|
|
6
9
|
*/
|
|
7
|
-
export declare function getRandom(
|
|
10
|
+
export declare function getRandom(rng?: RNG): float;
|
|
8
11
|
/**
|
|
9
12
|
* This returns a random float between min and max. It is inclusive on the low end, but exclusive on
|
|
10
13
|
* the high end. (This is because the `RNG.RandomFloat` method can return a value of 0.999, but it
|
|
11
14
|
* will never return a value of exactly 1.)
|
|
12
15
|
*
|
|
16
|
+
* Note that this function will invoke the `Next` method on the `RNG` object before returning the
|
|
17
|
+
* random number.
|
|
18
|
+
*
|
|
13
19
|
* Example:
|
|
14
20
|
* ```ts
|
|
15
|
-
* const realNumberBetweenOneAndThree = getRandomFloat(1, 3
|
|
21
|
+
* const realNumberBetweenOneAndThree = getRandomFloat(1, 3);
|
|
16
22
|
* ```
|
|
17
23
|
*/
|
|
18
|
-
export declare function getRandomFloat(min: int, max: int,
|
|
24
|
+
export declare function getRandomFloat(min: int, max: int, rng?: RNG): float;
|
|
19
25
|
/**
|
|
20
|
-
* This returns a random
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
* This returns a random float between min and max. It is inclusive on the low end, but exclusive on
|
|
27
|
+
* the high end. (This is because the `RNG.RandomFloat` method can return a value of 0.999, but it
|
|
28
|
+
* will never return a value of exactly 1.)
|
|
29
|
+
*/
|
|
30
|
+
export declare function getRandomFloatFromSeed(min: int, max: int, seed: Seed): float;
|
|
31
|
+
/**
|
|
32
|
+
* This returns a random float between 0 and 1. It is inclusive on the low end, but exclusive on
|
|
33
|
+
* the high end. (This is because the `RNG.RandomFloat` method can return a value of 0.999, but it
|
|
34
|
+
* will never return a value of exactly 1.)
|
|
26
35
|
*/
|
|
27
|
-
export declare function
|
|
36
|
+
export declare function getRandomFromSeed(seed: Seed): float;
|
|
28
37
|
/**
|
|
29
|
-
*
|
|
38
|
+
* This returns a random integer between min and max. It is inclusive on both ends.
|
|
39
|
+
*
|
|
40
|
+
* Note that this function will invoke the `Next` method on the `RNG` object before returning the
|
|
41
|
+
* random number.
|
|
30
42
|
*
|
|
31
43
|
* Example:
|
|
32
44
|
* ```ts
|
|
33
|
-
* const
|
|
34
|
-
* const rng = initRNG(startSeed);
|
|
35
|
-
* const fiftyFiftyChance = rng.RandomInt(2) === 0;
|
|
45
|
+
* const oneTwoOrThree = getRandomInt(1, 3);
|
|
36
46
|
* ```
|
|
37
|
-
*
|
|
38
|
-
* It is recommended to not deal with RNG objects directly and instead use seeds. Also see the
|
|
39
|
-
* `getRandom`, `getRandomInt`, and `getRandomFloat` helper functions.
|
|
40
|
-
*
|
|
41
|
-
* @param seed The seed to initialize it with. Default is `Random()`.
|
|
42
|
-
*/
|
|
43
|
-
export declare function initRNG(seed?: Seed): RNG;
|
|
44
|
-
/**
|
|
45
|
-
* Helper function to get the next seed value.
|
|
46
|
-
*
|
|
47
|
-
* This function is useful because it is standard practice to work with seed values directly over
|
|
48
|
-
* RNG objects, since the latter are not serializable.
|
|
49
47
|
*/
|
|
50
|
-
export declare function
|
|
48
|
+
export declare function getRandomInt(min: int, max: int, rng?: RNG): int;
|
|
49
|
+
/** This returns a random integer between min and max. It is inclusive on both ends. */
|
|
50
|
+
export declare function getRandomIntFromSeed(min: int, max: int, seed: Seed): int;
|
|
@@ -1,41 +1,47 @@
|
|
|
1
1
|
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
2
|
local ____exports = {}
|
|
3
|
-
local
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
local ____rng = require("functions.rng")
|
|
4
|
+
local newRNG = ____rng.newRNG
|
|
5
|
+
function ____exports.getRandom(self, rng)
|
|
6
|
+
if rng == nil then
|
|
7
|
+
rng = newRNG(nil)
|
|
7
8
|
end
|
|
8
|
-
if seed == 0 then
|
|
9
|
-
error("You cannot initialize an RNG object with a seed of 0, or the game will crash.")
|
|
10
|
-
end
|
|
11
|
-
local rng = RNG()
|
|
12
|
-
rng:SetSeed(seed, RECOMMENDED_SHIFT_IDX)
|
|
13
|
-
return rng
|
|
14
|
-
end
|
|
15
|
-
RECOMMENDED_SHIFT_IDX = 35
|
|
16
|
-
function ____exports.getRandom(self, seed)
|
|
17
|
-
if seed == nil then
|
|
18
|
-
seed = Random()
|
|
19
|
-
end
|
|
20
|
-
local rng = ____exports.initRNG(nil, seed)
|
|
21
9
|
return rng:RandomFloat()
|
|
22
10
|
end
|
|
23
|
-
function ____exports.getRandomFloat(self, min, max,
|
|
24
|
-
if
|
|
25
|
-
|
|
11
|
+
function ____exports.getRandomFloat(self, min, max, rng)
|
|
12
|
+
if rng == nil then
|
|
13
|
+
rng = newRNG(nil)
|
|
14
|
+
end
|
|
15
|
+
if min > max then
|
|
16
|
+
local oldMin = min
|
|
17
|
+
local oldMax = max
|
|
18
|
+
min = oldMax
|
|
19
|
+
max = oldMin
|
|
26
20
|
end
|
|
27
|
-
return min + ____exports.getRandom(nil,
|
|
21
|
+
return min + ____exports.getRandom(nil, rng) * (max - min)
|
|
28
22
|
end
|
|
29
|
-
function ____exports.
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
function ____exports.getRandomFloatFromSeed(self, min, max, seed)
|
|
24
|
+
local rng = newRNG(nil, seed)
|
|
25
|
+
return ____exports.getRandomFloat(nil, min, max, rng)
|
|
26
|
+
end
|
|
27
|
+
function ____exports.getRandomFromSeed(self, seed)
|
|
28
|
+
local rng = newRNG(nil, seed)
|
|
29
|
+
return ____exports.getRandom(nil, rng)
|
|
30
|
+
end
|
|
31
|
+
function ____exports.getRandomInt(self, min, max, rng)
|
|
32
|
+
if rng == nil then
|
|
33
|
+
rng = newRNG(nil)
|
|
34
|
+
end
|
|
35
|
+
if min > max then
|
|
36
|
+
local oldMin = min
|
|
37
|
+
local oldMax = max
|
|
38
|
+
min = oldMax
|
|
39
|
+
max = oldMin
|
|
32
40
|
end
|
|
33
|
-
local rng = ____exports.initRNG(nil, seed)
|
|
34
41
|
return rng:RandomInt(max - min + 1) + min
|
|
35
42
|
end
|
|
36
|
-
function ____exports.
|
|
37
|
-
local rng =
|
|
38
|
-
rng
|
|
39
|
-
return rng:GetSeed()
|
|
43
|
+
function ____exports.getRandomIntFromSeed(self, min, max, seed)
|
|
44
|
+
local rng = newRNG(nil, seed)
|
|
45
|
+
return ____exports.getRandomInt(nil, min, max, rng)
|
|
40
46
|
end
|
|
41
47
|
return ____exports
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
local ____exports = {}
|
|
3
3
|
local ____cachedClasses = require("cachedClasses")
|
|
4
4
|
local game = ____cachedClasses.game
|
|
5
|
+
local ____constants = require("constants")
|
|
6
|
+
local MAX_TAINTED_SAMSON_BERSERK_CHARGE = ____constants.MAX_TAINTED_SAMSON_BERSERK_CHARGE
|
|
7
|
+
local TAINTED_SAMSON_BERSERK_CHARGE_FROM_TAKING_DAMAGE = ____constants.TAINTED_SAMSON_BERSERK_CHARGE_FROM_TAKING_DAMAGE
|
|
5
8
|
local ____character = require("functions.character")
|
|
6
9
|
local getCharacterDeathAnimationName = ____character.getCharacterDeathAnimationName
|
|
7
10
|
local ____player = require("functions.player")
|
|
@@ -44,6 +47,10 @@ function ____exports.isDamageToPlayerFatal(self, player, damageAmount, damageSou
|
|
|
44
47
|
if isBerserk then
|
|
45
48
|
return false
|
|
46
49
|
end
|
|
50
|
+
local berserkChargeAfterHit = player.SamsonBerserkCharge + TAINTED_SAMSON_BERSERK_CHARGE_FROM_TAKING_DAMAGE
|
|
51
|
+
if character == PlayerType.PLAYER_SAMSON_B and berserkChargeAfterHit >= MAX_TAINTED_SAMSON_BERSERK_CHARGE then
|
|
52
|
+
return false
|
|
53
|
+
end
|
|
47
54
|
if ____exports.willReviveFromSpiritShackles(nil, player) then
|
|
48
55
|
return false
|
|
49
56
|
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="typescript-to-lua/language-extensions" />
|
|
3
|
+
import { SerializationType } from "../enums/SerializationType";
|
|
4
|
+
declare type SerializedRNG = LuaTable<string, string | number>;
|
|
5
|
+
interface CopyRNGReturn {
|
|
6
|
+
[SerializationType.NONE]: RNG;
|
|
7
|
+
[SerializationType.SERIALIZE]: SerializedRNG;
|
|
8
|
+
[SerializationType.DESERIALIZE]: RNG;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Helper function to copy an `RNG` object.
|
|
12
|
+
*
|
|
13
|
+
* @param rng The RNG object to copy. In the case of deserialization, this will actually be a Lua
|
|
14
|
+
* table instead of an instantiated RNG class.
|
|
15
|
+
* @param serializationType Default is `SerializationType.NONE`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function copyRNG<R extends RNG | SerializedRNG, S extends SerializationType>(rng: R, serializationType: S): CopyRNGReturn[S];
|
|
18
|
+
/**
|
|
19
|
+
* Helper function to get a random `Seed` value to be used in spawning entities and so on. Use this
|
|
20
|
+
* instead of calling the `Random` function directly since that can return a value of 0 and crash
|
|
21
|
+
* the game.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getRandomSeed(): Seed;
|
|
24
|
+
/** Helper function to check if something is an instantiated RNG object. */
|
|
25
|
+
export declare function isRNG(object: unknown): object is RNG;
|
|
26
|
+
/**
|
|
27
|
+
* Used to determine is the given table is a serialized Vector created by the save data manager
|
|
28
|
+
* and/or the `deepCopy` function.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isSerializedRNG(object: unknown): object is SerializedRNG;
|
|
31
|
+
/**
|
|
32
|
+
* Helper function to initialize an RNG object using Blade's recommended shift index.
|
|
33
|
+
*
|
|
34
|
+
* @param seed The seed to initialize it with. Default is `getRandomSeed()`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function newRNG(seed?: Seed): RNG;
|
|
37
|
+
/**
|
|
38
|
+
* Helper function to get the next seed value.
|
|
39
|
+
*
|
|
40
|
+
* This function is useful if you are working with data structures that store seed values instead of
|
|
41
|
+
* RNG objects.
|
|
42
|
+
*/
|
|
43
|
+
export declare function nextSeed(seed: Seed): Seed;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____exports = {}
|
|
3
|
+
local RECOMMENDED_SHIFT_IDX, OBJECT_NAME
|
|
4
|
+
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
5
|
+
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
6
|
+
local ____SerializationType = require("enums.SerializationType")
|
|
7
|
+
local SerializationType = ____SerializationType.SerializationType
|
|
8
|
+
local ____table = require("functions.table")
|
|
9
|
+
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
10
|
+
local tableHasKeys = ____table.tableHasKeys
|
|
11
|
+
local ____utils = require("functions.utils")
|
|
12
|
+
local ensureAllCases = ____utils.ensureAllCases
|
|
13
|
+
local isUserdataObject = ____utils.isUserdataObject
|
|
14
|
+
function ____exports.getRandomSeed(self)
|
|
15
|
+
local randomNumber = Random()
|
|
16
|
+
local safeRandomNumber = randomNumber == 0 and 1 or randomNumber
|
|
17
|
+
return safeRandomNumber
|
|
18
|
+
end
|
|
19
|
+
function ____exports.isRNG(self, object)
|
|
20
|
+
return isUserdataObject(nil, object, OBJECT_NAME)
|
|
21
|
+
end
|
|
22
|
+
function ____exports.newRNG(self, seed)
|
|
23
|
+
if seed == nil then
|
|
24
|
+
seed = ____exports.getRandomSeed(nil)
|
|
25
|
+
end
|
|
26
|
+
if seed == 0 then
|
|
27
|
+
error("You cannot initialize an RNG object with a seed of 0, or the game will crash.")
|
|
28
|
+
end
|
|
29
|
+
local rng = RNG()
|
|
30
|
+
rng:SetSeed(seed, RECOMMENDED_SHIFT_IDX)
|
|
31
|
+
return rng
|
|
32
|
+
end
|
|
33
|
+
RECOMMENDED_SHIFT_IDX = 35
|
|
34
|
+
local KEYS = {"seed"}
|
|
35
|
+
OBJECT_NAME = "RNG"
|
|
36
|
+
function ____exports.copyRNG(self, rng, serializationType)
|
|
37
|
+
if serializationType == nil then
|
|
38
|
+
serializationType = SerializationType.NONE
|
|
39
|
+
end
|
|
40
|
+
repeat
|
|
41
|
+
local ____switch3 = serializationType
|
|
42
|
+
local ____cond3 = ____switch3 == SerializationType.NONE
|
|
43
|
+
if ____cond3 then
|
|
44
|
+
do
|
|
45
|
+
if not ____exports.isRNG(nil, rng) then
|
|
46
|
+
error(((("Failed to copy a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
47
|
+
end
|
|
48
|
+
local seed = rng:GetSeed()
|
|
49
|
+
return ____exports.newRNG(nil, seed)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
____cond3 = ____cond3 or ____switch3 == SerializationType.SERIALIZE
|
|
53
|
+
if ____cond3 then
|
|
54
|
+
do
|
|
55
|
+
if not ____exports.isRNG(nil, rng) then
|
|
56
|
+
error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
57
|
+
end
|
|
58
|
+
local seed = rng:GetSeed()
|
|
59
|
+
local rngTable = {}
|
|
60
|
+
rngTable.seed = seed
|
|
61
|
+
rngTable[SerializationBrand.RNG] = ""
|
|
62
|
+
return rngTable
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
____cond3 = ____cond3 or ____switch3 == SerializationType.DESERIALIZE
|
|
66
|
+
if ____cond3 then
|
|
67
|
+
do
|
|
68
|
+
local rngType = type(rng)
|
|
69
|
+
if ____exports.isRNG(nil, rng) or rngType ~= "table" then
|
|
70
|
+
error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object was not a Lua table.")
|
|
71
|
+
end
|
|
72
|
+
local seedNumber = table.unpack(getNumbersFromTable(
|
|
73
|
+
nil,
|
|
74
|
+
rng,
|
|
75
|
+
OBJECT_NAME,
|
|
76
|
+
table.unpack(KEYS)
|
|
77
|
+
))
|
|
78
|
+
local seed = seedNumber
|
|
79
|
+
return ____exports.newRNG(nil, seed)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
do
|
|
83
|
+
do
|
|
84
|
+
return ensureAllCases(nil, serializationType)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
until true
|
|
88
|
+
end
|
|
89
|
+
function ____exports.isSerializedRNG(self, object)
|
|
90
|
+
local objectType = type(object)
|
|
91
|
+
if objectType ~= "table" then
|
|
92
|
+
return false
|
|
93
|
+
end
|
|
94
|
+
local ____table = object
|
|
95
|
+
return tableHasKeys(
|
|
96
|
+
nil,
|
|
97
|
+
____table,
|
|
98
|
+
table.unpack(KEYS)
|
|
99
|
+
) and ____table[SerializationBrand.RNG] ~= nil
|
|
100
|
+
end
|
|
101
|
+
function ____exports.nextSeed(self, seed)
|
|
102
|
+
local rng = ____exports.newRNG(nil, seed)
|
|
103
|
+
rng:Next()
|
|
104
|
+
return rng:GetSeed()
|
|
105
|
+
end
|
|
106
|
+
return ____exports
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
* `RoomDescriptor` object that you are retrieving.
|
|
5
5
|
*/
|
|
6
6
|
export declare function getCurrentRoomDescriptorReadOnly(): RoomDescriptorReadOnly;
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to get the set of allowed door slots for the room at the supplied grid index.
|
|
9
|
+
* This corresponds to the doors that are enabled in the STB/XML file for the room.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getRoomAllowedDoors(roomGridIndex?: int): Set<DoorSlot>;
|
|
7
12
|
/**
|
|
8
13
|
* Helper function to get the room data for the provided room.
|
|
9
14
|
*
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Set = ____lualib.Set
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
2
4
|
local ____exports = {}
|
|
3
5
|
local ____cachedClasses = require("cachedClasses")
|
|
4
6
|
local game = ____cachedClasses.game
|
|
7
|
+
local ____flag = require("functions.flag")
|
|
8
|
+
local hasFlag = ____flag.hasFlag
|
|
9
|
+
local ____utils = require("functions.utils")
|
|
10
|
+
local getEnumValues = ____utils.getEnumValues
|
|
5
11
|
function ____exports.getCurrentRoomDescriptorReadOnly(self)
|
|
6
12
|
local level = game:GetLevel()
|
|
7
13
|
return level:GetCurrentRoomDesc()
|
|
8
14
|
end
|
|
15
|
+
function ____exports.getRoomData(self, roomGridIndex)
|
|
16
|
+
local roomDescriptor = ____exports.getRoomDescriptor(nil, roomGridIndex)
|
|
17
|
+
return roomDescriptor.Data
|
|
18
|
+
end
|
|
9
19
|
function ____exports.getRoomDescriptor(self, roomGridIndex)
|
|
10
20
|
local level = game:GetLevel()
|
|
11
21
|
if roomGridIndex == nil then
|
|
@@ -22,9 +32,26 @@ function ____exports.getRoomGridIndex(self)
|
|
|
22
32
|
local roomDescriptor = ____exports.getCurrentRoomDescriptorReadOnly(nil)
|
|
23
33
|
return roomDescriptor.SafeGridIndex
|
|
24
34
|
end
|
|
25
|
-
function ____exports.
|
|
26
|
-
local
|
|
27
|
-
|
|
35
|
+
function ____exports.getRoomAllowedDoors(self, roomGridIndex)
|
|
36
|
+
local allowedDoors = __TS__New(Set)
|
|
37
|
+
local roomData = ____exports.getRoomData(nil, roomGridIndex)
|
|
38
|
+
if roomData == nil then
|
|
39
|
+
return allowedDoors
|
|
40
|
+
end
|
|
41
|
+
local doorSlots = getEnumValues(nil, DoorSlot)
|
|
42
|
+
for ____, doorSlot in ipairs(doorSlots) do
|
|
43
|
+
do
|
|
44
|
+
if doorSlot == DoorSlot.NO_DOOR_SLOT or doorSlot == DoorSlot.NUM_DOOR_SLOTS then
|
|
45
|
+
goto __continue5
|
|
46
|
+
end
|
|
47
|
+
local doorSlotFlag = 1 << doorSlot
|
|
48
|
+
if hasFlag(nil, roomData.Doors, doorSlotFlag) then
|
|
49
|
+
allowedDoors:add(doorSlot)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
::__continue5::
|
|
53
|
+
end
|
|
54
|
+
return allowedDoors
|
|
28
55
|
end
|
|
29
56
|
function ____exports.getRoomListIndex(self, roomGridIndex)
|
|
30
57
|
local roomDescriptor = ____exports.getRoomDescriptor(nil, roomGridIndex)
|
package/dist/functions/set.d.ts
CHANGED
|
@@ -25,10 +25,10 @@ export declare function deleteSetsFromSet<T>(mainSet: Set<T>, ...setsToRemove: A
|
|
|
25
25
|
* Helper function to get a random element from the provided set.
|
|
26
26
|
*
|
|
27
27
|
* @param set The set to get an element from.
|
|
28
|
-
* @param
|
|
28
|
+
* @param rng Optional. The RNG object used to select the random element. Default is `newRNG()`.
|
|
29
29
|
* @param exceptions Optional. An array of elements to skip over if selected.
|
|
30
30
|
*/
|
|
31
|
-
export declare function getRandomSetElement<T>(set: Set<T> | ReadonlySet<T>,
|
|
31
|
+
export declare function getRandomSetElement<T>(set: Set<T> | ReadonlySet<T>, rng?: RNG, exceptions?: T[] | readonly T[]): T;
|
|
32
32
|
/**
|
|
33
33
|
* Helper function to get a sorted array based on the contents of a set.
|
|
34
34
|
*
|
package/dist/functions/set.lua
CHANGED
|
@@ -7,6 +7,8 @@ local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
|
7
7
|
local ____exports = {}
|
|
8
8
|
local ____array = require("functions.array")
|
|
9
9
|
local getRandomArrayElement = ____array.getRandomArrayElement
|
|
10
|
+
local ____rng = require("functions.rng")
|
|
11
|
+
local newRNG = ____rng.newRNG
|
|
10
12
|
function ____exports.getSortedSetValues(self, set)
|
|
11
13
|
local values = set:values()
|
|
12
14
|
local array = {__TS__Spread(values)}
|
|
@@ -46,14 +48,14 @@ function ____exports.deleteSetsFromSet(self, mainSet, ...)
|
|
|
46
48
|
end
|
|
47
49
|
end
|
|
48
50
|
end
|
|
49
|
-
function ____exports.getRandomSetElement(self, set,
|
|
50
|
-
if
|
|
51
|
-
|
|
51
|
+
function ____exports.getRandomSetElement(self, set, rng, exceptions)
|
|
52
|
+
if rng == nil then
|
|
53
|
+
rng = newRNG(nil)
|
|
52
54
|
end
|
|
53
55
|
if exceptions == nil then
|
|
54
56
|
exceptions = {}
|
|
55
57
|
end
|
|
56
58
|
local array = ____exports.getSortedSetValues(nil, set)
|
|
57
|
-
return getRandomArrayElement(nil, array,
|
|
59
|
+
return getRandomArrayElement(nil, array, rng, exceptions)
|
|
58
60
|
end
|
|
59
61
|
return ____exports
|
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @param collectibleType The collectible type to spawn.
|
|
9
9
|
* @param position The position to spawn the collectible at.
|
|
10
|
-
* @param
|
|
10
|
+
* @param rng Optional. Default is `newRNG()`.
|
|
11
11
|
* @param options Optional. Set to true to make the collectible a "There's Options" style
|
|
12
12
|
* collectible. Default is false.
|
|
13
13
|
* @param forceFreeItem Optional. Set to true to disable the logic that gives the item a price for
|
|
14
14
|
* Tainted Keeper. Default is false.
|
|
15
15
|
*/
|
|
16
|
-
export declare function spawnCollectible(collectibleType: CollectibleType | int, position: Vector,
|
|
16
|
+
export declare function spawnCollectible(collectibleType: CollectibleType | int, position: Vector, rng?: RNG, options?: boolean, forceFreeItem?: boolean): EntityPickup;
|
|
17
17
|
/**
|
|
18
18
|
* Helper function to spawn an empty collectible. Doing this is tricky since spawning a collectible
|
|
19
19
|
* with `CollectibleType.COLLECTIBLE_NULL` will result in spawning a collectible with a random type
|
|
@@ -22,4 +22,4 @@ export declare function spawnCollectible(collectibleType: CollectibleType | int,
|
|
|
22
22
|
* Instead, this function arbitrarily spawns a collectible with
|
|
23
23
|
* `CollectibleType.COLLECTIBLE_SAD_ONION`, and then converts it to an empty pedestal afterward.
|
|
24
24
|
*/
|
|
25
|
-
export declare function spawnEmptyCollectible(position: Vector,
|
|
25
|
+
export declare function spawnEmptyCollectible(position: Vector, rng?: RNG): EntityPickup;
|
|
@@ -11,9 +11,11 @@ local isQuestCollectible = ____collectibles.isQuestCollectible
|
|
|
11
11
|
local setCollectibleEmpty = ____collectibles.setCollectibleEmpty
|
|
12
12
|
local ____player = require("functions.player")
|
|
13
13
|
local anyPlayerIs = ____player.anyPlayerIs
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
local ____rng = require("functions.rng")
|
|
15
|
+
local newRNG = ____rng.newRNG
|
|
16
|
+
function ____exports.spawnCollectible(self, collectibleType, position, rng, options, forceFreeItem)
|
|
17
|
+
if rng == nil then
|
|
18
|
+
rng = newRNG(nil)
|
|
17
19
|
end
|
|
18
20
|
if options == nil then
|
|
19
21
|
options = false
|
|
@@ -21,9 +23,8 @@ function ____exports.spawnCollectible(self, collectibleType, position, seed, opt
|
|
|
21
23
|
if forceFreeItem == nil then
|
|
22
24
|
forceFreeItem = false
|
|
23
25
|
end
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
end
|
|
26
|
+
rng:Next()
|
|
27
|
+
local seed = rng:GetSeed()
|
|
27
28
|
local collectible = game:Spawn(
|
|
28
29
|
EntityType.ENTITY_PICKUP,
|
|
29
30
|
100,
|
|
@@ -48,15 +49,15 @@ function ____exports.spawnCollectible(self, collectibleType, position, seed, opt
|
|
|
48
49
|
end
|
|
49
50
|
return collectible
|
|
50
51
|
end
|
|
51
|
-
function ____exports.spawnEmptyCollectible(self, position,
|
|
52
|
-
if
|
|
53
|
-
|
|
52
|
+
function ____exports.spawnEmptyCollectible(self, position, rng)
|
|
53
|
+
if rng == nil then
|
|
54
|
+
rng = newRNG(nil)
|
|
54
55
|
end
|
|
55
56
|
local collectible = ____exports.spawnCollectible(
|
|
56
57
|
nil,
|
|
57
58
|
CollectibleType.COLLECTIBLE_SAD_ONION,
|
|
58
59
|
position,
|
|
59
|
-
|
|
60
|
+
rng,
|
|
60
61
|
false,
|
|
61
62
|
true
|
|
62
63
|
)
|
|
@@ -4,3 +4,33 @@
|
|
|
4
4
|
* `clear` method does not exist. Use this helper function as a drop-in replacement for this.
|
|
5
5
|
*/
|
|
6
6
|
export declare function clearTable(table: LuaTable): void;
|
|
7
|
+
/** Helper function to copy specific values from a object to a table. */
|
|
8
|
+
export declare function copyValuesToTable(object: unknown, keys: string[], table: LuaTable<string, string | number>): void;
|
|
9
|
+
/**
|
|
10
|
+
* Helper function to safely get boolean values from a Lua table. Will throw an error if the
|
|
11
|
+
* specific value does not exist on the table.
|
|
12
|
+
*
|
|
13
|
+
* This function is variadic, meaning that you can specify N arguments to get N values.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getBooleansFromTable(table: LuaTable<string, string | number>, objectName: string, ...keys: string[]): boolean[];
|
|
16
|
+
/**
|
|
17
|
+
* Helper function to safely get number values from a Lua table. Will throw an error if the specific
|
|
18
|
+
* value does not exist on the table or if it cannot be converted to a number.
|
|
19
|
+
*
|
|
20
|
+
* This function is variadic, meaning that you can specify N arguments to get N values.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getNumbersFromTable(table: LuaTable<string, string | number>, objectName: string, ...keys: string[]): number[];
|
|
23
|
+
/**
|
|
24
|
+
* Helper function to safely get string values from a Lua table. Will throw an error if the specific
|
|
25
|
+
* value does not exist on the table.
|
|
26
|
+
*
|
|
27
|
+
* This function is variadic, meaning that you can specify N arguments to get N values.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getStringsFromTable(table: LuaTable<string, string | number>, objectName: string, ...keys: string[]): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to check if a Lua table has all of the provided keys.
|
|
32
|
+
*
|
|
33
|
+
* This function is variadic, meaning that you can specify as many arguments as you want to check
|
|
34
|
+
* for.
|
|
35
|
+
*/
|
|
36
|
+
export declare function tableHasKeys(table: LuaTable, ...keys: string[]): boolean;
|
package/dist/functions/table.lua
CHANGED
|
@@ -1,8 +1,80 @@
|
|
|
1
|
-
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
|
|
3
|
+
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
4
|
+
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
|
|
2
5
|
local ____exports = {}
|
|
3
6
|
function ____exports.clearTable(self, ____table)
|
|
4
7
|
for key in pairs(____table) do
|
|
5
8
|
____table[key] = nil
|
|
6
9
|
end
|
|
7
10
|
end
|
|
11
|
+
function ____exports.copyValuesToTable(self, object, keys, ____table)
|
|
12
|
+
local otherTable = object
|
|
13
|
+
for ____, key in ipairs(keys) do
|
|
14
|
+
local value = otherTable[key]
|
|
15
|
+
____table[key] = value
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
function ____exports.getBooleansFromTable(self, ____table, objectName, ...)
|
|
19
|
+
local keys = {...}
|
|
20
|
+
local booleans = {}
|
|
21
|
+
for ____, key in ipairs(keys) do
|
|
22
|
+
local value = ____table[key]
|
|
23
|
+
if value == nil then
|
|
24
|
+
error(((("Failed to find a value for \"" .. key) .. "\" in a table representing a \"") .. objectName) .. "\" object.")
|
|
25
|
+
end
|
|
26
|
+
if type(value) == "boolean" then
|
|
27
|
+
__TS__ArrayPush(booleans, value)
|
|
28
|
+
else
|
|
29
|
+
error((((("Failed to get the boolean for the \"" .. key) .. "\" value of a table representing a \"") .. objectName) .. "\" object because the type was: ") .. __TS__TypeOf(value))
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
return booleans
|
|
33
|
+
end
|
|
34
|
+
function ____exports.getNumbersFromTable(self, ____table, objectName, ...)
|
|
35
|
+
local keys = {...}
|
|
36
|
+
local numbers = {}
|
|
37
|
+
for ____, key in ipairs(keys) do
|
|
38
|
+
local value = ____table[key]
|
|
39
|
+
if value == nil then
|
|
40
|
+
error(((("Failed to find a value for \"" .. key) .. "\" in a table representing a \"") .. objectName) .. "\" object.")
|
|
41
|
+
end
|
|
42
|
+
if type(value) == "number" then
|
|
43
|
+
__TS__ArrayPush(numbers, value)
|
|
44
|
+
elseif type(value) == "string" then
|
|
45
|
+
local number = tonumber(value)
|
|
46
|
+
if number == nil then
|
|
47
|
+
error((((("Failed to convert the \"" .. key) .. "\" value of a table representing a \"") .. objectName) .. "\" object to a number: ") .. value)
|
|
48
|
+
end
|
|
49
|
+
__TS__ArrayPush(numbers, number)
|
|
50
|
+
else
|
|
51
|
+
error((((("Failed to get the number for the \"" .. key) .. "\" value of a table representing a \"") .. objectName) .. "\" object because the type was: ") .. __TS__TypeOf(value))
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
return numbers
|
|
55
|
+
end
|
|
56
|
+
function ____exports.getStringsFromTable(self, ____table, objectName, ...)
|
|
57
|
+
local keys = {...}
|
|
58
|
+
local strings = {}
|
|
59
|
+
for ____, key in ipairs(keys) do
|
|
60
|
+
local value = ____table[key]
|
|
61
|
+
if value == nil then
|
|
62
|
+
error(((("Failed to find a value for \"" .. key) .. "\" in a table representing a \"") .. objectName) .. "\" object.")
|
|
63
|
+
end
|
|
64
|
+
if type(value) == "string" then
|
|
65
|
+
__TS__ArrayPush(strings, value)
|
|
66
|
+
else
|
|
67
|
+
local ____string = tostring(value)
|
|
68
|
+
__TS__ArrayPush(strings, ____string)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
return strings
|
|
72
|
+
end
|
|
73
|
+
function ____exports.tableHasKeys(self, ____table, ...)
|
|
74
|
+
local keys = {...}
|
|
75
|
+
return __TS__ArrayEvery(
|
|
76
|
+
keys,
|
|
77
|
+
function(____, key) return ____table[key] ~= nil end
|
|
78
|
+
)
|
|
79
|
+
end
|
|
8
80
|
return ____exports
|
|
@@ -93,6 +93,11 @@ export declare function hexToKColor(hexString: string, alpha: float): KColor;
|
|
|
93
93
|
* is enabled or not.
|
|
94
94
|
*/
|
|
95
95
|
export declare function isLuaDebugEnabled(): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Helper function to check if the something is an instantiated class from the Isaac API. (All
|
|
98
|
+
* classes from the Isaac API have a type of "userdata" in Lua.)
|
|
99
|
+
*/
|
|
100
|
+
export declare function isUserdataObject(object: unknown, objectName: string): boolean;
|
|
96
101
|
/**
|
|
97
102
|
* Helper function to print something to the in-game console. Use this instead of invoking the
|
|
98
103
|
* `Isaac.ConsoleOutput` method directly because it will automatically insert a newline at the end
|
package/dist/functions/utils.lua
CHANGED
|
@@ -66,6 +66,18 @@ end
|
|
|
66
66
|
function ____exports.isLuaDebugEnabled(self)
|
|
67
67
|
return package ~= nil
|
|
68
68
|
end
|
|
69
|
+
function ____exports.isUserdataObject(self, object, objectName)
|
|
70
|
+
local objectType = type(object)
|
|
71
|
+
if objectType ~= "userdata" then
|
|
72
|
+
return false
|
|
73
|
+
end
|
|
74
|
+
local metatable = getmetatable(object)
|
|
75
|
+
if metatable == nil then
|
|
76
|
+
return false
|
|
77
|
+
end
|
|
78
|
+
local vectorMetatable = metatable
|
|
79
|
+
return vectorMetatable.__type == objectName
|
|
80
|
+
end
|
|
69
81
|
function ____exports.printConsole(self, msg)
|
|
70
82
|
Isaac.ConsoleOutput(msg .. "\n")
|
|
71
83
|
end
|