Debug Functions
Functions
Section titled “Functions”getElapsedTimeSince()
Section titled “getElapsedTimeSince()”getElapsedTimeSince(
time,useSocketIfAvailable?):int
Defined in: packages/isaacscript-common/src/functions/debugFunctions.ts:13
Helper function to get the amount of elapsed time for benchmarking / profiling purposes.
For more information, see the documentation for the getTime helper function.
Parameters
Section titled “Parameters”int | float
The milliseconds (int) or fractional seconds (float).
useSocketIfAvailable?
Section titled “useSocketIfAvailable?”boolean = true
Optional. Whether to use the socket.gettime method, if available.
Default is true. If set to false, the Isaac.GetTime() method will
always be used.
Returns
Section titled “Returns”int
getTime()
Section titled “getTime()”getTime(
useSocketIfAvailable?):int|float
Defined in: packages/isaacscript-common/src/functions/debugFunctions.ts:38
Helper function to get the current time for benchmarking / profiling purposes.
The return value will either be in seconds or milliseconds, depending on if the “–luadebug” flag is turned on.
If the “–luadebug” flag is present, then this function will use the socket.gettime method,
which returns the epoch timestamp in seconds (e.g. “1640320492.5779”). This is preferable over
the more conventional Isaac.GetTime method, since it has one extra decimal point of precision.
If the “–luadebug” flag is not present, then this function will use the Isaac.GetTime method,
which returns the number of milliseconds since the computer’s operating system was started (e.g.
“739454963”).
Parameters
Section titled “Parameters”useSocketIfAvailable?
Section titled “useSocketIfAvailable?”boolean = true
Optional. Whether to use the socket.gettime method, if available.
Default is true. If set to false, the Isaac.GetTime() method will
always be used.
Returns
Section titled “Returns”int | float
getTraceback()
Section titled “getTraceback()”getTraceback(
this):string
Defined in: packages/isaacscript-common/src/functions/debugFunctions.ts:65
Helper function to get a stack trace.
This will only work if the --luadebug launch option is enabled. If it isn’t, then a error
string will be returned.
Parameters
Section titled “Parameters”void
Returns
Section titled “Returns”string
isLuaDebugEnabled()
Section titled “isLuaDebugEnabled()”isLuaDebugEnabled():
boolean
Defined in: packages/isaacscript-common/src/functions/debugFunctions.ts:95
Players can boot the game with an launch option called “–luadebug”, which will enable additional functionality that is considered to be unsafe. For more information about this flag, see the wiki: https://bindingofisaacrebirth.fandom.com/wiki/Launch_Options
When this flag is enabled, the global environment will be slightly different. The differences are documented here: https://wofsauge.github.io/IsaacDocs/rep/Globals.html
This function uses the package global variable as a proxy to determine if the “–luadebug” flag
is enabled.
Note that this function will return false if the Racing+ sandbox is enabled, even if the
“–luadebug” flag is really turned on. If checking for this case is needed, check for the
presence of the sandboxGetTraceback function.
Returns
Section titled “Returns”boolean
traceback()
Section titled “traceback()”traceback(
this):void
Defined in: packages/isaacscript-common/src/functions/debugFunctions.ts:108
Helper function to log a stack trace to the “log.txt” file, similar to JavaScript’s
console.trace function.
This will only work if the --luadebug launch option is enabled. If it isn’t, then a error
string will be logged.
Parameters
Section titled “Parameters”void
Returns
Section titled “Returns”void
