-
Notifications
You must be signed in to change notification settings - Fork 4
Debug
MSU adds functionality to improve the debugging capabilites of the user.
It allows you to register a mod for debugging,
optionally registering additional flags.
This allows the user to leave debugging information in the code,
but turn off specific parts when distributing the mod.
Every registered mod has a default flag.
This allows for simple syntax, such as YourNamespace.Mod.printLog("text")
.
If you want more granularity,
you can add further flags to turn debug on and off
for specific areas of the mod.
<Mod>.register( ::MSU.System.Debug, _defaultFlagBool = false, _flagTable = null, _flagTableBool = null )
// _defaultFlagBool and _flagTableBool are booleans
// _flagTable is a table of string : boolean entries
_defaultFlagBool
sets the value of the default
flag
_flagTable
is an optional table of flagID
: flagBool
pairs
and must be of form { flag1 = false, flag2 = true ...}
,
see this.MSU.System.Debug.MSUDebugFlags (TODO) for an example.
If passed, sets these flags via setFlags.
_flagTableBool
is an optional boolean for setFlags.
local MSUDebugFlags = {
debug = true,
movement = true,
skills = false,
keybinds = false
};
::MSU.Mod.register(::MSU.System.Debug, true, MSUDebugFlags);
<Mod>.Debug.printLog( _printText, _flagID = null ) // printWarning/printError
// _printText and _flag ID are strings
Substitutes for this.logInfo
, this.logWarning
and this.logError
Print the log as _printText
if debugging is enabled.
_flagID
specifies a flag of the mod,
and is set to default if left empty.
<Mod>.Debug.setFlag( _flagID, _flagBool )
// _flagID is a string
// _flagBool is a boolean
Sets (and creates if necessary) the flag _flag
to _flagBool
<Mod>.Debug.setFlags( _flagTable, _flagTableBool = null )
// _flagTable is a table of string : boolean entries
// _flagTableBool is a boolean
Calls setFlag(key, value)
on each entry in _flagTable
.
If _flagTableBool
is not null, calls setFlag(key, _flagTableBool)
on each entry instead.
<Mod>.Debug.isEnabled( _flagID = "default" )
Returns true if debugging is enabled for _flagID
.
Returns false otherwise.
::YourNamespace.Mod.register(::MSU.System.Debug, true);
// we've now enabled the default flag for our mod so when we do
::YourNamespace.Mod.Debug.printLog("Test");
// it will print to the log.
local newFlags = {
flag1 = true,
flag2 = false
}
// now we create a new flagTable
::YourNamespace.Mod.Debug.setFlags(newFlags);
// and add it to our mod
::YourNamespace.Mod.Debug.printWarning("Prints!", "flag1");
// this would still print because flag1 = true
::YourNamespace.Mod.Debug.printError("Does not print!", "flag2");
// would not print because flag2 = false, but if we do
::YourNamespace.Mod.Debug.setFlag("flag2", true);
::YourNamespace.Mod.Debug.printError("Prints!", "flag2")
// this will now print to the log
- NOTE: MSU guarantees backwards compatibility for documented features and code only. Undocumented features/code of MSU may be changed at any time without notice, so we advise against using/referencing such code in your projects.
- For bug reports or feature requests, please create issues.
- If you would like to join the team, write to us at msu.team@protonmail.com.