isaacscript-common 79.0.0 → 79.1.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/dist/classes/callbacks/PostPlayerInitFirst.lua +4 -5
- package/dist/enums/ModCallbackCustom.d.ts +1 -1
- package/dist/functions/levelGrid.d.ts +6 -1
- package/dist/functions/levelGrid.d.ts.map +1 -1
- package/dist/functions/levelGrid.lua +4 -1
- package/dist/functions/rng.d.ts.map +1 -1
- package/dist/functions/rng.lua +3 -0
- package/dist/functions/roomData.d.ts +3 -2
- package/dist/functions/roomData.d.ts.map +1 -1
- package/dist/functions/roomData.lua +3 -2
- package/dist/functions/roomShape.d.ts +13 -0
- package/dist/functions/roomShape.d.ts.map +1 -1
- package/dist/functions/roomShape.lua +9 -0
- package/dist/functions/rooms.d.ts +7 -7
- package/dist/functions/rooms.d.ts.map +1 -1
- package/dist/functions/rooms.lua +19 -19
- package/dist/index.rollup.d.ts +30 -10
- package/dist/interfaces/private/AddCallbackParametersCustom.d.ts +1 -1
- package/dist/interfaces/private/AddCallbackParametersCustom.d.ts.map +1 -1
- package/dist/isaacscript-common.lua +210 -195
- package/package.json +2 -2
- package/src/classes/callbacks/PostPlayerInitFirst.ts +6 -6
- package/src/enums/ModCallbackCustom.ts +1 -1
- package/src/functions/levelGrid.ts +6 -1
- package/src/functions/rng.ts +2 -0
- package/src/functions/roomData.ts +3 -2
- package/src/functions/roomShape.ts +16 -0
- package/src/functions/rooms.ts +20 -23
- package/src/interfaces/private/AddCallbackParametersCustom.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common
|
|
3
|
+
isaacscript-common 79.1.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -17362,6 +17362,173 @@ ____exports.SerializationBrand.VECTOR = "__VECTOR"
|
|
|
17362
17362
|
____exports.SerializationBrand.DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE"
|
|
17363
17363
|
____exports.SerializationBrand.OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS"
|
|
17364
17364
|
____exports.SerializationBrand.TSTL_CLASS = "__TSTL_CLASS"
|
|
17365
|
+
return ____exports
|
|
17366
|
+
end,
|
|
17367
|
+
["functions.log"] = function(...)
|
|
17368
|
+
local ____exports = {}
|
|
17369
|
+
local ____types = require("functions.types")
|
|
17370
|
+
local isNumber = ____types.isNumber
|
|
17371
|
+
--- Helper function to get the name and the line number of the current calling function.
|
|
17372
|
+
--
|
|
17373
|
+
-- For this function to work properly, the "--luadebug" flag must be enabled. Otherwise, it will
|
|
17374
|
+
-- always return undefined.
|
|
17375
|
+
--
|
|
17376
|
+
-- @param levels Optional. The amount of levels to look backwards in the call stack. Default is 3
|
|
17377
|
+
-- (because the first level is this function, the second level is the calling
|
|
17378
|
+
-- function, and the third level is the parent of the calling function).
|
|
17379
|
+
function ____exports.getParentFunctionDescription(levels)
|
|
17380
|
+
if levels == nil then
|
|
17381
|
+
levels = 3
|
|
17382
|
+
end
|
|
17383
|
+
if debug ~= nil then
|
|
17384
|
+
local debugTable = debug.getinfo(levels)
|
|
17385
|
+
if debugTable ~= nil then
|
|
17386
|
+
return (tostring(debugTable.name) .. ":") .. tostring(debugTable.linedefined)
|
|
17387
|
+
end
|
|
17388
|
+
end
|
|
17389
|
+
if SandboxGetParentFunctionDescription ~= nil then
|
|
17390
|
+
return SandboxGetParentFunctionDescription(levels)
|
|
17391
|
+
end
|
|
17392
|
+
return nil
|
|
17393
|
+
end
|
|
17394
|
+
--- Helper function to avoid typing out `Isaac.DebugString()`.
|
|
17395
|
+
--
|
|
17396
|
+
-- If you have the "--luadebug" launch flag turned on, then this function will also prepend the
|
|
17397
|
+
-- function name and the line number before the string, like this:
|
|
17398
|
+
--
|
|
17399
|
+
-- ```text
|
|
17400
|
+
-- [INFO] - Lua Debug: saveToDisk:42494 - The save data manager wrote data to the "save#.dat" file.
|
|
17401
|
+
-- ```
|
|
17402
|
+
--
|
|
17403
|
+
-- Subsequently, it is recommended that you turn on the "--luadebug" launch flag when developing
|
|
17404
|
+
-- your mod so that debugging becomes a little bit easier.
|
|
17405
|
+
--
|
|
17406
|
+
-- @param msg The message to log.
|
|
17407
|
+
-- @param includeParentFunction Optional. Whether to prefix the message with the function name and
|
|
17408
|
+
-- line number, as shown in the above example. Default is true.
|
|
17409
|
+
function ____exports.log(msg, includeParentFunction)
|
|
17410
|
+
if includeParentFunction == nil then
|
|
17411
|
+
includeParentFunction = true
|
|
17412
|
+
end
|
|
17413
|
+
if isNumber(nil, msg) then
|
|
17414
|
+
msg = tostring(msg)
|
|
17415
|
+
end
|
|
17416
|
+
local ____includeParentFunction_0
|
|
17417
|
+
if includeParentFunction then
|
|
17418
|
+
____includeParentFunction_0 = ____exports.getParentFunctionDescription()
|
|
17419
|
+
else
|
|
17420
|
+
____includeParentFunction_0 = nil
|
|
17421
|
+
end
|
|
17422
|
+
local parentFunctionDescription = ____includeParentFunction_0
|
|
17423
|
+
local debugMsg = parentFunctionDescription == nil and msg or (parentFunctionDescription .. " - ") .. msg
|
|
17424
|
+
Isaac.DebugString(debugMsg)
|
|
17425
|
+
end
|
|
17426
|
+
--- Helper function to log a message to the "log.txt" file and to print it to the screen at the same
|
|
17427
|
+
-- time.
|
|
17428
|
+
function ____exports.logAndPrint(self, msg)
|
|
17429
|
+
____exports.log(msg)
|
|
17430
|
+
print(msg)
|
|
17431
|
+
end
|
|
17432
|
+
--- Helper function to log an error message and also print it to the console for better visibility.
|
|
17433
|
+
--
|
|
17434
|
+
-- This is useful in situations where using the `error` function would be dangerous (since it
|
|
17435
|
+
-- prevents all of the subsequent code in the callback from running).
|
|
17436
|
+
function ____exports.logError(msg)
|
|
17437
|
+
local errorMsg = "Error: " .. msg
|
|
17438
|
+
____exports.logAndPrint(nil, errorMsg)
|
|
17439
|
+
end
|
|
17440
|
+
return ____exports
|
|
17441
|
+
end,
|
|
17442
|
+
["functions.debugFunctions"] = function(...)
|
|
17443
|
+
local ____exports = {}
|
|
17444
|
+
local ____log = require("functions.log")
|
|
17445
|
+
local log = ____log.log
|
|
17446
|
+
--- Helper function to get the current time for benchmarking / profiling purposes.
|
|
17447
|
+
--
|
|
17448
|
+
-- The return value will either be in seconds or milliseconds, depending on if the "--luadebug" flag
|
|
17449
|
+
-- is turned on.
|
|
17450
|
+
--
|
|
17451
|
+
-- If the "--luadebug" flag is present, then this function will use the `socket.gettime` method,
|
|
17452
|
+
-- which returns the epoch timestamp in seconds (e.g. "1640320492.5779"). This is preferable over
|
|
17453
|
+
-- the more conventional `Isaac.GetTime` method, since it has one extra decimal point of precision.
|
|
17454
|
+
--
|
|
17455
|
+
-- If the "--luadebug" flag is not present, then this function will use the `Isaac.GetTime` method,
|
|
17456
|
+
-- which returns the number of milliseconds since the computer's operating system was started (e.g.
|
|
17457
|
+
-- "739454963").
|
|
17458
|
+
--
|
|
17459
|
+
-- @param useSocketIfAvailable Optional. Whether to use the `socket.gettime` method, if available.
|
|
17460
|
+
-- Default is true. If set to false, the `Isaac.GetTime()` method will
|
|
17461
|
+
-- always be used.
|
|
17462
|
+
function ____exports.getTime(self, useSocketIfAvailable)
|
|
17463
|
+
if useSocketIfAvailable == nil then
|
|
17464
|
+
useSocketIfAvailable = true
|
|
17465
|
+
end
|
|
17466
|
+
if useSocketIfAvailable then
|
|
17467
|
+
if SandboxGetTime ~= nil then
|
|
17468
|
+
return SandboxGetTime()
|
|
17469
|
+
end
|
|
17470
|
+
if ____exports.isLuaDebugEnabled(nil) then
|
|
17471
|
+
local ok, requiredSocket = pcall(require, "socket")
|
|
17472
|
+
if ok then
|
|
17473
|
+
local socket = requiredSocket
|
|
17474
|
+
return socket.gettime()
|
|
17475
|
+
end
|
|
17476
|
+
end
|
|
17477
|
+
end
|
|
17478
|
+
return Isaac.GetTime()
|
|
17479
|
+
end
|
|
17480
|
+
--- Players can boot the game with an launch option called "--luadebug", which will enable additional
|
|
17481
|
+
-- functionality that is considered to be unsafe. For more information about this flag, see the
|
|
17482
|
+
-- wiki: https://bindingofisaacrebirth.fandom.com/wiki/Launch_Options
|
|
17483
|
+
--
|
|
17484
|
+
-- When this flag is enabled, the global environment will be slightly different. The differences are
|
|
17485
|
+
-- documented here: https://wofsauge.github.io/IsaacDocs/rep/Globals.html
|
|
17486
|
+
--
|
|
17487
|
+
-- This function uses the `package` global variable as a proxy to determine if the "--luadebug" flag
|
|
17488
|
+
-- is enabled.
|
|
17489
|
+
--
|
|
17490
|
+
-- Note that this function will return false if the Racing+ sandbox is enabled, even if the
|
|
17491
|
+
-- "--luadebug" flag is really turned on. If checking for this case is needed, check for the
|
|
17492
|
+
-- presence of the `sandboxGetTraceback` function.
|
|
17493
|
+
function ____exports.isLuaDebugEnabled(self)
|
|
17494
|
+
return _G.package ~= nil
|
|
17495
|
+
end
|
|
17496
|
+
--- Helper function to get the amount of elapsed time for benchmarking / profiling purposes.
|
|
17497
|
+
--
|
|
17498
|
+
-- For more information, see the documentation for the `getTime` helper function.
|
|
17499
|
+
--
|
|
17500
|
+
-- @param time The milliseconds (int) or fractional seconds (float).
|
|
17501
|
+
-- @param useSocketIfAvailable Optional. Whether to use the `socket.gettime` method, if available.
|
|
17502
|
+
-- Default is true. If set to false, the `Isaac.GetTime()` method will
|
|
17503
|
+
-- always be used.
|
|
17504
|
+
function ____exports.getElapsedTimeSince(self, time, useSocketIfAvailable)
|
|
17505
|
+
if useSocketIfAvailable == nil then
|
|
17506
|
+
useSocketIfAvailable = true
|
|
17507
|
+
end
|
|
17508
|
+
return ____exports.getTime(nil, useSocketIfAvailable) - time
|
|
17509
|
+
end
|
|
17510
|
+
--- Helper function to get a stack trace.
|
|
17511
|
+
--
|
|
17512
|
+
-- This will only work if the `--luadebug` launch option is enabled. If it isn't, then a error
|
|
17513
|
+
-- string will be returned.
|
|
17514
|
+
function ____exports.getTraceback()
|
|
17515
|
+
if SandboxGetTraceback ~= nil then
|
|
17516
|
+
return SandboxGetTraceback()
|
|
17517
|
+
end
|
|
17518
|
+
if debug ~= nil then
|
|
17519
|
+
return debug.traceback()
|
|
17520
|
+
end
|
|
17521
|
+
return "stack traceback:\n(the \"--luadebug\" flag is not enabled)"
|
|
17522
|
+
end
|
|
17523
|
+
--- Helper function to log a stack trace to the "log.txt" file, similar to JavaScript's
|
|
17524
|
+
-- `console.trace` function.
|
|
17525
|
+
--
|
|
17526
|
+
-- This will only work if the `--luadebug` launch option is enabled. If it isn't, then a error
|
|
17527
|
+
-- string will be logged.
|
|
17528
|
+
function ____exports.traceback()
|
|
17529
|
+
local tracebackOutput = ____exports.getTraceback()
|
|
17530
|
+
log(tracebackOutput)
|
|
17531
|
+
end
|
|
17365
17532
|
return ____exports
|
|
17366
17533
|
end,
|
|
17367
17534
|
["types.PlayerIndex"] = function(...)
|
|
@@ -18062,81 +18229,6 @@ function ____exports.isaacAPIClassEquals(self, object1, object2, keys)
|
|
|
18062
18229
|
function(____, key) return table1[key] == table2[key] end
|
|
18063
18230
|
)
|
|
18064
18231
|
end
|
|
18065
|
-
return ____exports
|
|
18066
|
-
end,
|
|
18067
|
-
["functions.log"] = function(...)
|
|
18068
|
-
local ____exports = {}
|
|
18069
|
-
local ____types = require("functions.types")
|
|
18070
|
-
local isNumber = ____types.isNumber
|
|
18071
|
-
--- Helper function to get the name and the line number of the current calling function.
|
|
18072
|
-
--
|
|
18073
|
-
-- For this function to work properly, the "--luadebug" flag must be enabled. Otherwise, it will
|
|
18074
|
-
-- always return undefined.
|
|
18075
|
-
--
|
|
18076
|
-
-- @param levels Optional. The amount of levels to look backwards in the call stack. Default is 3
|
|
18077
|
-
-- (because the first level is this function, the second level is the calling
|
|
18078
|
-
-- function, and the third level is the parent of the calling function).
|
|
18079
|
-
function ____exports.getParentFunctionDescription(levels)
|
|
18080
|
-
if levels == nil then
|
|
18081
|
-
levels = 3
|
|
18082
|
-
end
|
|
18083
|
-
if debug ~= nil then
|
|
18084
|
-
local debugTable = debug.getinfo(levels)
|
|
18085
|
-
if debugTable ~= nil then
|
|
18086
|
-
return (tostring(debugTable.name) .. ":") .. tostring(debugTable.linedefined)
|
|
18087
|
-
end
|
|
18088
|
-
end
|
|
18089
|
-
if SandboxGetParentFunctionDescription ~= nil then
|
|
18090
|
-
return SandboxGetParentFunctionDescription(levels)
|
|
18091
|
-
end
|
|
18092
|
-
return nil
|
|
18093
|
-
end
|
|
18094
|
-
--- Helper function to avoid typing out `Isaac.DebugString()`.
|
|
18095
|
-
--
|
|
18096
|
-
-- If you have the "--luadebug" launch flag turned on, then this function will also prepend the
|
|
18097
|
-
-- function name and the line number before the string, like this:
|
|
18098
|
-
--
|
|
18099
|
-
-- ```text
|
|
18100
|
-
-- [INFO] - Lua Debug: saveToDisk:42494 - The save data manager wrote data to the "save#.dat" file.
|
|
18101
|
-
-- ```
|
|
18102
|
-
--
|
|
18103
|
-
-- Subsequently, it is recommended that you turn on the "--luadebug" launch flag when developing
|
|
18104
|
-
-- your mod so that debugging becomes a little bit easier.
|
|
18105
|
-
--
|
|
18106
|
-
-- @param msg The message to log.
|
|
18107
|
-
-- @param includeParentFunction Optional. Whether to prefix the message with the function name and
|
|
18108
|
-
-- line number, as shown in the above example. Default is true.
|
|
18109
|
-
function ____exports.log(msg, includeParentFunction)
|
|
18110
|
-
if includeParentFunction == nil then
|
|
18111
|
-
includeParentFunction = true
|
|
18112
|
-
end
|
|
18113
|
-
if isNumber(nil, msg) then
|
|
18114
|
-
msg = tostring(msg)
|
|
18115
|
-
end
|
|
18116
|
-
local ____includeParentFunction_0
|
|
18117
|
-
if includeParentFunction then
|
|
18118
|
-
____includeParentFunction_0 = ____exports.getParentFunctionDescription()
|
|
18119
|
-
else
|
|
18120
|
-
____includeParentFunction_0 = nil
|
|
18121
|
-
end
|
|
18122
|
-
local parentFunctionDescription = ____includeParentFunction_0
|
|
18123
|
-
local debugMsg = parentFunctionDescription == nil and msg or (parentFunctionDescription .. " - ") .. msg
|
|
18124
|
-
Isaac.DebugString(debugMsg)
|
|
18125
|
-
end
|
|
18126
|
-
--- Helper function to log a message to the "log.txt" file and to print it to the screen at the same
|
|
18127
|
-
-- time.
|
|
18128
|
-
function ____exports.logAndPrint(self, msg)
|
|
18129
|
-
____exports.log(msg)
|
|
18130
|
-
print(msg)
|
|
18131
|
-
end
|
|
18132
|
-
--- Helper function to log an error message and also print it to the console for better visibility.
|
|
18133
|
-
--
|
|
18134
|
-
-- This is useful in situations where using the `error` function would be dangerous (since it
|
|
18135
|
-
-- prevents all of the subsequent code in the callback from running).
|
|
18136
|
-
function ____exports.logError(msg)
|
|
18137
|
-
local errorMsg = "Error: " .. msg
|
|
18138
|
-
____exports.logAndPrint(nil, errorMsg)
|
|
18139
|
-
end
|
|
18140
18232
|
return ____exports
|
|
18141
18233
|
end,
|
|
18142
18234
|
["functions.table"] = function(...)
|
|
@@ -18306,6 +18398,8 @@ local ____cachedClasses = require("core.cachedClasses")
|
|
|
18306
18398
|
local game = ____cachedClasses.game
|
|
18307
18399
|
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
18308
18400
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
18401
|
+
local ____debugFunctions = require("functions.debugFunctions")
|
|
18402
|
+
local traceback = ____debugFunctions.traceback
|
|
18309
18403
|
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
18310
18404
|
local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
|
|
18311
18405
|
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
@@ -18346,6 +18440,7 @@ function ____exports.setSeed(self, rng, seed)
|
|
|
18346
18440
|
if seed == 0 then
|
|
18347
18441
|
seed = ____exports.getRandomSeed(nil)
|
|
18348
18442
|
logError("Failed to set a RNG object to a seed of 0. Using a random value instead.")
|
|
18443
|
+
traceback()
|
|
18349
18444
|
end
|
|
18350
18445
|
rng:SetSeed(seed, RECOMMENDED_SHIFT_IDX)
|
|
18351
18446
|
end
|
|
@@ -28888,14 +28983,23 @@ end
|
|
|
28888
28983
|
function ____exports.getRoomShapeWidth(self, roomShape)
|
|
28889
28984
|
return ROOM_SHAPE_TO_GRID_WIDTH[roomShape]
|
|
28890
28985
|
end
|
|
28986
|
+
--- Helper function to determine if the provided room is equal to `RoomShape.1x2` (4) or
|
|
28987
|
+
-- `RoomShape.2x1` (6).
|
|
28988
|
+
function ____exports.is2x1RoomShape(self, roomShape)
|
|
28989
|
+
return roomShape == RoomShape.SHAPE_1x2 or roomShape == RoomShape.SHAPE_2x1
|
|
28990
|
+
end
|
|
28891
28991
|
--- Helper function to detect if the provided room shape is big. Specifically, this is all 1x2 rooms,
|
|
28892
28992
|
-- 2x2 rooms, and L rooms.
|
|
28893
28993
|
function ____exports.isBigRoomShape(self, roomShape)
|
|
28894
28994
|
return BIG_ROOM_SHAPES_SET:has(roomShape)
|
|
28895
28995
|
end
|
|
28996
|
+
--- Helper function to determine if the provided room is equal to `RoomShape.LTL` (9),
|
|
28997
|
+
-- `RoomShape.LTR` (10), `RoomShape.LBL` (11), or `RoomShape.LBR` (12).
|
|
28896
28998
|
function ____exports.isLRoomShape(self, roomShape)
|
|
28897
28999
|
return L_ROOM_SHAPES_SET:has(roomShape)
|
|
28898
29000
|
end
|
|
29001
|
+
--- Helper function to determine if the provided room is equal to `RoomShape.IH` (2), `RoomShape.IV`
|
|
29002
|
+
-- (3), `RoomShape.IIV` (5), or `RoomShape.IIH` (7).
|
|
28899
29003
|
function ____exports.isNarrowRoom(self, roomShape)
|
|
28900
29004
|
return NARROW_ROOM_SHAPES_SET:has(roomShape)
|
|
28901
29005
|
end
|
|
@@ -31199,9 +31303,10 @@ end
|
|
|
31199
31303
|
-- the room descriptor. (The safe grid index is defined as the top-left 1x1 section that the room
|
|
31200
31304
|
-- overlaps with, or the top-right 1x1 section of a `RoomType.SHAPE_LTL` room.)
|
|
31201
31305
|
-- - If the current room is outside of the grid, it will return the index from the
|
|
31202
|
-
-- `Level.GetCurrentRoomIndex` method
|
|
31306
|
+
-- `Level.GetCurrentRoomIndex` method, since `SafeGridIndex` is bugged for these cases, as
|
|
31203
31307
|
-- demonstrated by entering a Genesis room and entering `l
|
|
31204
|
-
-- print(Game():GetLevel():GetCurrentRoomDesc().SafeGridIndex)` into the console
|
|
31308
|
+
-- print(Game():GetLevel():GetCurrentRoomDesc().SafeGridIndex)` into the console. (It prints -1
|
|
31309
|
+
-- instead of -12.)
|
|
31205
31310
|
--
|
|
31206
31311
|
-- Use this function instead of the `Level.GetCurrentRoomIndex` method directly because the latter
|
|
31207
31312
|
-- will return the specific 1x1 quadrant that the player entered the room at. For most situations,
|
|
@@ -32347,7 +32452,6 @@ local GridRoom = ____isaac_2Dtypescript_2Ddefinitions.GridRoom
|
|
|
32347
32452
|
local HomeRoomSubType = ____isaac_2Dtypescript_2Ddefinitions.HomeRoomSubType
|
|
32348
32453
|
local ProjectileFlag = ____isaac_2Dtypescript_2Ddefinitions.ProjectileFlag
|
|
32349
32454
|
local RoomDescriptorFlag = ____isaac_2Dtypescript_2Ddefinitions.RoomDescriptorFlag
|
|
32350
|
-
local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
|
|
32351
32455
|
local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
|
|
32352
32456
|
local SoundEffect = ____isaac_2Dtypescript_2Ddefinitions.SoundEffect
|
|
32353
32457
|
local StageID = ____isaac_2Dtypescript_2Ddefinitions.StageID
|
|
@@ -32386,6 +32490,7 @@ local getRoomDescriptor = ____roomData.getRoomDescriptor
|
|
|
32386
32490
|
local getRoomDescriptorReadOnly = ____roomData.getRoomDescriptorReadOnly
|
|
32387
32491
|
local getRoomGridIndex = ____roomData.getRoomGridIndex
|
|
32388
32492
|
local ____roomShape = require("functions.roomShape")
|
|
32493
|
+
local is2x1RoomShape = ____roomShape.is2x1RoomShape
|
|
32389
32494
|
local isBigRoomShape = ____roomShape.isBigRoomShape
|
|
32390
32495
|
local isLRoomShape = ____roomShape.isLRoomShape
|
|
32391
32496
|
local ____roomTransition = require("functions.roomTransition")
|
|
@@ -32466,7 +32571,7 @@ function ____exports.getRoomsOutsideGrid(self)
|
|
|
32466
32571
|
end
|
|
32467
32572
|
--- Helper function to determine if the provided room is equal to `RoomShape.1x2` or `RoomShape.2x1`.
|
|
32468
32573
|
function ____exports.is2x1Room(self, roomData)
|
|
32469
|
-
return
|
|
32574
|
+
return is2x1RoomShape(nil, roomData.Shape)
|
|
32470
32575
|
end
|
|
32471
32576
|
--- Helper function to check to see if the current room is an angel shop.
|
|
32472
32577
|
--
|
|
@@ -32543,8 +32648,8 @@ function ____exports.isDoubleTrouble(self, roomData)
|
|
|
32543
32648
|
return roomData.Type == RoomType.BOSS and __TS__StringIncludes(roomData.Name, "Double Trouble")
|
|
32544
32649
|
end
|
|
32545
32650
|
--- Helper function to determine if the index of the provided room is equal to `GridRoom.GENESIS`.
|
|
32546
|
-
function ____exports.isGenesisRoom(self,
|
|
32547
|
-
return
|
|
32651
|
+
function ____exports.isGenesisRoom(self, roomGridIndex)
|
|
32652
|
+
return roomGridIndex == asNumber(nil, GridRoom.GENESIS)
|
|
32548
32653
|
end
|
|
32549
32654
|
--- Helper function to check if the provided room is either the left Home closet (behind the red
|
|
32550
32655
|
-- door) or the right Home closet (with one random pickup).
|
|
@@ -32558,8 +32663,8 @@ function ____exports.isLRoom(self, roomData)
|
|
|
32558
32663
|
return isLRoomShape(nil, roomData.Shape)
|
|
32559
32664
|
end
|
|
32560
32665
|
--- Helper function to determine if the index of the provided room is equal to `GridRoom.MEGA_SATAN`.
|
|
32561
|
-
function ____exports.isMegaSatanRoom(self,
|
|
32562
|
-
return
|
|
32666
|
+
function ____exports.isMegaSatanRoom(self, roomGridIndex)
|
|
32667
|
+
return roomGridIndex == asNumber(nil, GridRoom.MEGA_SATAN)
|
|
32563
32668
|
end
|
|
32564
32669
|
--- Helper function to determine if the provided room is part of the Repentance "escape sequence" in
|
|
32565
32670
|
-- the Mines/Ashpit.
|
|
@@ -32592,8 +32697,8 @@ function ____exports.isRoomType(self, roomData, ...)
|
|
|
32592
32697
|
end
|
|
32593
32698
|
--- Helper function for checking if the provided room is a secret exit that leads to a Repentance
|
|
32594
32699
|
-- floor.
|
|
32595
|
-
function ____exports.isSecretExit(self,
|
|
32596
|
-
return
|
|
32700
|
+
function ____exports.isSecretExit(self, roomGridIndex)
|
|
32701
|
+
return roomGridIndex == asNumber(nil, GridRoom.SECRET_EXIT)
|
|
32597
32702
|
end
|
|
32598
32703
|
--- Helper function for checking if the provided room is a secret shop (from the Member Card
|
|
32599
32704
|
-- collectible).
|
|
@@ -32601,8 +32706,8 @@ end
|
|
|
32601
32706
|
-- Secret shops are simply copies of normal shops, but with the backdrop of a secret room. In other
|
|
32602
32707
|
-- words, they will have the same room type, room variant, and room sub-type of a normal shop. Thus,
|
|
32603
32708
|
-- the only way to detect them is by using the grid index.
|
|
32604
|
-
function ____exports.isSecretShop(self,
|
|
32605
|
-
return
|
|
32709
|
+
function ____exports.isSecretShop(self, roomGridIndex)
|
|
32710
|
+
return roomGridIndex == asNumber(nil, GridRoom.SECRET_SHOP)
|
|
32606
32711
|
end
|
|
32607
32712
|
local SECRET_ROOM_TYPES = __TS__New(ReadonlySet, {RoomType.SECRET, RoomType.SUPER_SECRET, RoomType.ULTRA_SECRET})
|
|
32608
32713
|
--- Helper function for quickly switching to a new room without playing a particular animation. Use
|
|
@@ -32680,7 +32785,7 @@ end
|
|
|
32680
32785
|
--- Helper function to get the room descriptor for every room on the level. This includes off-grid
|
|
32681
32786
|
-- rooms, such as the Devil Room.
|
|
32682
32787
|
--
|
|
32683
|
-
-- Room
|
|
32788
|
+
-- Room without any data are assumed to be non-existent and are not included.
|
|
32684
32789
|
--
|
|
32685
32790
|
-- - If you want just the rooms inside of the grid, use the `getRoomsInsideGrid` helper function.
|
|
32686
32791
|
-- - If you want just the rooms outside of the grid, use the `getRoomsOutsideGrid` helper function.
|
|
@@ -32810,8 +32915,8 @@ function ____exports.inDoubleTrouble(self)
|
|
|
32810
32915
|
end
|
|
32811
32916
|
--- Helper function to determine if the current room index is equal to `GridRoom.GENESIS`.
|
|
32812
32917
|
function ____exports.inGenesisRoom(self)
|
|
32813
|
-
local
|
|
32814
|
-
return ____exports.isGenesisRoom(nil,
|
|
32918
|
+
local roomGridIndex = getRoomGridIndex(nil)
|
|
32919
|
+
return ____exports.isGenesisRoom(nil, roomGridIndex)
|
|
32815
32920
|
end
|
|
32816
32921
|
--- Helper function to check if the current room is either the left Home closet (behind the red door)
|
|
32817
32922
|
-- or the right Home closet (with one random pickup).
|
|
@@ -32828,8 +32933,8 @@ function ____exports.inLRoom(self)
|
|
|
32828
32933
|
end
|
|
32829
32934
|
--- Helper function to determine if the current room index is equal to `GridRoom.MEGA_SATAN`.
|
|
32830
32935
|
function ____exports.inMegaSatanRoom(self)
|
|
32831
|
-
local
|
|
32832
|
-
return ____exports.isMegaSatanRoom(nil,
|
|
32936
|
+
local roomGridIndex = getRoomGridIndex(nil)
|
|
32937
|
+
return ____exports.isMegaSatanRoom(nil, roomGridIndex)
|
|
32833
32938
|
end
|
|
32834
32939
|
--- Helper function to determine if the current room is part of the Repentance "escape sequence" in
|
|
32835
32940
|
-- the Mines/Ashpit.
|
|
@@ -32866,8 +32971,8 @@ end
|
|
|
32866
32971
|
--- Helper function for checking if the current room is a secret exit that leads to a Repentance
|
|
32867
32972
|
-- floor.
|
|
32868
32973
|
function ____exports.inSecretExit(self)
|
|
32869
|
-
local
|
|
32870
|
-
return ____exports.isSecretExit(nil,
|
|
32974
|
+
local roomGridIndex = getRoomGridIndex(nil)
|
|
32975
|
+
return ____exports.isSecretExit(nil, roomGridIndex)
|
|
32871
32976
|
end
|
|
32872
32977
|
--- Helper function for checking if the current room is a secret shop (from the Member Card
|
|
32873
32978
|
-- collectible).
|
|
@@ -32876,8 +32981,8 @@ end
|
|
|
32876
32981
|
-- words, they will have the same room type, room variant, and room sub-type of a normal shop. Thus,
|
|
32877
32982
|
-- the only way to detect them is by using the grid index.
|
|
32878
32983
|
function ____exports.inSecretShop(self)
|
|
32879
|
-
local
|
|
32880
|
-
return ____exports.isSecretShop(nil,
|
|
32984
|
+
local roomGridIndex = getRoomGridIndex(nil)
|
|
32985
|
+
return ____exports.isSecretShop(nil, roomGridIndex)
|
|
32881
32986
|
end
|
|
32882
32987
|
--- Helper function to determine whether the current room is the starting room of a floor. It only
|
|
32883
32988
|
-- returns true for the starting room of the primary dimension (meaning that being in the starting
|
|
@@ -37001,11 +37106,10 @@ function PostPlayerInitFirst.prototype.____constructor(self)
|
|
|
37001
37106
|
CustomCallback.prototype.____constructor(self)
|
|
37002
37107
|
self.shouldFire = shouldFirePlayer
|
|
37003
37108
|
self.postNewRoomReordered = function()
|
|
37004
|
-
if
|
|
37005
|
-
|
|
37006
|
-
|
|
37007
|
-
|
|
37008
|
-
self:fire(player)
|
|
37109
|
+
if inGenesisRoom(nil) then
|
|
37110
|
+
for ____, player in ipairs(getPlayers(nil)) do
|
|
37111
|
+
self:fire(player)
|
|
37112
|
+
end
|
|
37009
37113
|
end
|
|
37010
37114
|
end
|
|
37011
37115
|
self.postPlayerInitLate = function(____, player)
|
|
@@ -55456,7 +55560,10 @@ function ____exports.getAdjacentNonExistingRoomGridIndexes(self, roomGridIndex)
|
|
|
55456
55560
|
function(____, adjacentRoomGridIndex) return getRoomData(nil, adjacentRoomGridIndex) == nil end
|
|
55457
55561
|
)
|
|
55458
55562
|
end
|
|
55459
|
-
--- Helper function to get the room safe grid index for every room on the entire floor.
|
|
55563
|
+
--- Helper function to get the room safe grid index for every room on the entire floor. This includes
|
|
55564
|
+
-- off-grid rooms, such as the Devil Room.
|
|
55565
|
+
--
|
|
55566
|
+
-- Rooms without any data are assumed to be non-existent and are not included.
|
|
55460
55567
|
function ____exports.getAllRoomGridIndexes(self)
|
|
55461
55568
|
local rooms = getRooms(nil)
|
|
55462
55569
|
return __TS__ArrayMap(
|
|
@@ -63227,98 +63334,6 @@ function ____exports.getFeatures(self, mod, callbacks)
|
|
|
63227
63334
|
}
|
|
63228
63335
|
return features
|
|
63229
63336
|
end
|
|
63230
|
-
return ____exports
|
|
63231
|
-
end,
|
|
63232
|
-
["functions.debugFunctions"] = function(...)
|
|
63233
|
-
local ____exports = {}
|
|
63234
|
-
local ____log = require("functions.log")
|
|
63235
|
-
local log = ____log.log
|
|
63236
|
-
--- Helper function to get the current time for benchmarking / profiling purposes.
|
|
63237
|
-
--
|
|
63238
|
-
-- The return value will either be in seconds or milliseconds, depending on if the "--luadebug" flag
|
|
63239
|
-
-- is turned on.
|
|
63240
|
-
--
|
|
63241
|
-
-- If the "--luadebug" flag is present, then this function will use the `socket.gettime` method,
|
|
63242
|
-
-- which returns the epoch timestamp in seconds (e.g. "1640320492.5779"). This is preferable over
|
|
63243
|
-
-- the more conventional `Isaac.GetTime` method, since it has one extra decimal point of precision.
|
|
63244
|
-
--
|
|
63245
|
-
-- If the "--luadebug" flag is not present, then this function will use the `Isaac.GetTime` method,
|
|
63246
|
-
-- which returns the number of milliseconds since the computer's operating system was started (e.g.
|
|
63247
|
-
-- "739454963").
|
|
63248
|
-
--
|
|
63249
|
-
-- @param useSocketIfAvailable Optional. Whether to use the `socket.gettime` method, if available.
|
|
63250
|
-
-- Default is true. If set to false, the `Isaac.GetTime()` method will
|
|
63251
|
-
-- always be used.
|
|
63252
|
-
function ____exports.getTime(self, useSocketIfAvailable)
|
|
63253
|
-
if useSocketIfAvailable == nil then
|
|
63254
|
-
useSocketIfAvailable = true
|
|
63255
|
-
end
|
|
63256
|
-
if useSocketIfAvailable then
|
|
63257
|
-
if SandboxGetTime ~= nil then
|
|
63258
|
-
return SandboxGetTime()
|
|
63259
|
-
end
|
|
63260
|
-
if ____exports.isLuaDebugEnabled(nil) then
|
|
63261
|
-
local ok, requiredSocket = pcall(require, "socket")
|
|
63262
|
-
if ok then
|
|
63263
|
-
local socket = requiredSocket
|
|
63264
|
-
return socket.gettime()
|
|
63265
|
-
end
|
|
63266
|
-
end
|
|
63267
|
-
end
|
|
63268
|
-
return Isaac.GetTime()
|
|
63269
|
-
end
|
|
63270
|
-
--- Players can boot the game with an launch option called "--luadebug", which will enable additional
|
|
63271
|
-
-- functionality that is considered to be unsafe. For more information about this flag, see the
|
|
63272
|
-
-- wiki: https://bindingofisaacrebirth.fandom.com/wiki/Launch_Options
|
|
63273
|
-
--
|
|
63274
|
-
-- When this flag is enabled, the global environment will be slightly different. The differences are
|
|
63275
|
-
-- documented here: https://wofsauge.github.io/IsaacDocs/rep/Globals.html
|
|
63276
|
-
--
|
|
63277
|
-
-- This function uses the `package` global variable as a proxy to determine if the "--luadebug" flag
|
|
63278
|
-
-- is enabled.
|
|
63279
|
-
--
|
|
63280
|
-
-- Note that this function will return false if the Racing+ sandbox is enabled, even if the
|
|
63281
|
-
-- "--luadebug" flag is really turned on. If checking for this case is needed, check for the
|
|
63282
|
-
-- presence of the `sandboxGetTraceback` function.
|
|
63283
|
-
function ____exports.isLuaDebugEnabled(self)
|
|
63284
|
-
return _G.package ~= nil
|
|
63285
|
-
end
|
|
63286
|
-
--- Helper function to get the amount of elapsed time for benchmarking / profiling purposes.
|
|
63287
|
-
--
|
|
63288
|
-
-- For more information, see the documentation for the `getTime` helper function.
|
|
63289
|
-
--
|
|
63290
|
-
-- @param time The milliseconds (int) or fractional seconds (float).
|
|
63291
|
-
-- @param useSocketIfAvailable Optional. Whether to use the `socket.gettime` method, if available.
|
|
63292
|
-
-- Default is true. If set to false, the `Isaac.GetTime()` method will
|
|
63293
|
-
-- always be used.
|
|
63294
|
-
function ____exports.getElapsedTimeSince(self, time, useSocketIfAvailable)
|
|
63295
|
-
if useSocketIfAvailable == nil then
|
|
63296
|
-
useSocketIfAvailable = true
|
|
63297
|
-
end
|
|
63298
|
-
return ____exports.getTime(nil, useSocketIfAvailable) - time
|
|
63299
|
-
end
|
|
63300
|
-
--- Helper function to get a stack trace.
|
|
63301
|
-
--
|
|
63302
|
-
-- This will only work if the `--luadebug` launch option is enabled. If it isn't, then a error
|
|
63303
|
-
-- string will be returned.
|
|
63304
|
-
function ____exports.getTraceback()
|
|
63305
|
-
if SandboxGetTraceback ~= nil then
|
|
63306
|
-
return SandboxGetTraceback()
|
|
63307
|
-
end
|
|
63308
|
-
if debug ~= nil then
|
|
63309
|
-
return debug.traceback()
|
|
63310
|
-
end
|
|
63311
|
-
return "stack traceback:\n(the \"--luadebug\" flag is not enabled)"
|
|
63312
|
-
end
|
|
63313
|
-
--- Helper function to log a stack trace to the "log.txt" file, similar to JavaScript's
|
|
63314
|
-
-- `console.trace` function.
|
|
63315
|
-
--
|
|
63316
|
-
-- This will only work if the `--luadebug` launch option is enabled. If it isn't, then a error
|
|
63317
|
-
-- string will be logged.
|
|
63318
|
-
function ____exports.traceback()
|
|
63319
|
-
local tracebackOutput = ____exports.getTraceback()
|
|
63320
|
-
log(tracebackOutput)
|
|
63321
|
-
end
|
|
63322
63337
|
return ____exports
|
|
63323
63338
|
end,
|
|
63324
63339
|
["types.FunctionTuple"] = function(...)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "79.
|
|
3
|
+
"version": "79.1.1",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"lint": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/lint.mts"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"isaac-typescript-definitions": "^39.0.
|
|
40
|
+
"isaac-typescript-definitions": "^39.0.2"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -22,12 +22,12 @@ export class PostPlayerInitFirst extends CustomCallback<ModCallbackCustom.POST_P
|
|
|
22
22
|
// trinkets, pocket items, and stats, so they will need to be re-initialized like they would be
|
|
23
23
|
// at the beginning of a run. However, in this case, the `POST_PLAYER_INIT_FIRST` callback will
|
|
24
24
|
// not fire, because that only fires once per run. Thus, we explicitly handle this special case.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
// Note that whichever player uses Genesis, items will be removed from all players (at least in
|
|
26
|
+
// the case of Jacob & Esau).
|
|
27
|
+
if (inGenesisRoom()) {
|
|
28
|
+
for (const player of getPlayers()) {
|
|
29
|
+
this.fire(player);
|
|
30
|
+
}
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -1466,7 +1466,7 @@ export enum ModCallbackCustom {
|
|
|
1466
1466
|
* pickup: EntityPickup,
|
|
1467
1467
|
* variant: PickupVariant,
|
|
1468
1468
|
* subType: int,
|
|
1469
|
-
* ): [PickupVariant, int] | undefined {}
|
|
1469
|
+
* ): [pickupVariant: PickupVariant, subType: int] | undefined {}
|
|
1470
1470
|
* ```
|
|
1471
1471
|
*/
|
|
1472
1472
|
POST_PICKUP_SELECTION_FILTER,
|
|
@@ -115,7 +115,12 @@ export function getAdjacentRoomGridIndexes(
|
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Helper function to get the room safe grid index for every room on the entire floor. This includes
|
|
120
|
+
* off-grid rooms, such as the Devil Room.
|
|
121
|
+
*
|
|
122
|
+
* Rooms without any data are assumed to be non-existent and are not included.
|
|
123
|
+
*/
|
|
119
124
|
export function getAllRoomGridIndexes(): readonly int[] {
|
|
120
125
|
const rooms = getRooms();
|
|
121
126
|
return rooms.map((roomDescriptor) => roomDescriptor.SafeGridIndex);
|
package/src/functions/rng.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
|
|
2
2
|
import { game } from "../core/cachedClasses";
|
|
3
3
|
import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
4
|
+
import { traceback } from "./debugFunctions";
|
|
4
5
|
import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
|
|
5
6
|
import { logError } from "./log";
|
|
6
7
|
import { getNumbersFromTable, tableHasKeys } from "./table";
|
|
@@ -160,6 +161,7 @@ export function setSeed(rng: RNG, seed: Seed): void {
|
|
|
160
161
|
logError(
|
|
161
162
|
"Failed to set a RNG object to a seed of 0. Using a random value instead.",
|
|
162
163
|
);
|
|
164
|
+
traceback();
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
// The game expects seeds in the range of 1 to 4294967295 (1^32 - 1).
|
|
@@ -86,9 +86,10 @@ export function getRoomDescriptorReadOnly(): Readonly<RoomDescriptor> {
|
|
|
86
86
|
* the room descriptor. (The safe grid index is defined as the top-left 1x1 section that the room
|
|
87
87
|
* overlaps with, or the top-right 1x1 section of a `RoomType.SHAPE_LTL` room.)
|
|
88
88
|
* - If the current room is outside of the grid, it will return the index from the
|
|
89
|
-
* `Level.GetCurrentRoomIndex` method
|
|
89
|
+
* `Level.GetCurrentRoomIndex` method, since `SafeGridIndex` is bugged for these cases, as
|
|
90
90
|
* demonstrated by entering a Genesis room and entering `l
|
|
91
|
-
* print(Game():GetLevel():GetCurrentRoomDesc().SafeGridIndex)` into the console
|
|
91
|
+
* print(Game():GetLevel():GetCurrentRoomDesc().SafeGridIndex)` into the console. (It prints -1
|
|
92
|
+
* instead of -12.)
|
|
92
93
|
*
|
|
93
94
|
* Use this function instead of the `Level.GetCurrentRoomIndex` method directly because the latter
|
|
94
95
|
* will return the specific 1x1 quadrant that the player entered the room at. For most situations,
|