This is an old revision of the document!
This is a script that displays variables from a registered script in an in-game UI. This is useful to live debug variables without directly modifying the code.
To run, type this into the console:
run debugger <scriptName> [var1 var2 ...]
Optionally, variable names can be omitted from the console command if the targeted script has a list of variable names “debugVars” present.
if (<failed) return endif <vars 0 do <vars[i] " - " GetRegisteredScriptVar(<script <vars[i]) @ConcatAll >uiTable{<vars[i]} loop :Once GetArgs >args if (GetListCount(<args) eq0) Trace("<br>No target script was provided. Usage: run debugger <scriptName> [var1 var2 ...]") true >failed StopConsole endif <args[0] >script GetRegisteredScriptVar(<script "debugVars") >vars if (GetListCount(<vars) eq0) RemoveListElement(<args 0) <args >vars if (GetListCount(<args) eq0) Trace("<br>Targeted script either does not exist, isn't registered or does not have a debugVars list and no vars were provided with args. Usage: run debugger <scriptName> [var1 var2 ...]") true >failed StopConsole endif endif @CreateUI :Destroyed DestroyUI("debugger") :CreateUI DestroyUI("debugger") <vars 0 do "{ 'type': 'text', 'pos': [0," i -24 * "], 'width': 600, 'height': 24, 'name': '" <vars[i] "', 'color': '#fff', 'bgcolor': '#5557', 'text': '" <vars[i] " - " GetRegisteredScriptVar(<script <vars[i]) "'}," loop @ConcatAll >varsUI "{ 'anchor': [0,0.5], 'pos': [0,100], 'pivot': [0,0], 'width': 0, 'height': 0, 'bgcolor': '#0000', 'Components': [ { 'type': 'text', 'pos': [0,24], 'width': 600, 'height': 24, 'name': 'title', 'color': '#fff', 'bgcolor': '#5557', 'text': 'DEBUGGER'}, " <varsUI " ] } " @ConcatAll >ui CreateTable >uiTable CreateUI("debugger" <ui <uiTable) pop pop :ConcatAll StackSize 1 do Concat loop