Debug Print Lua
December 30, 2017 ยท View on GitHub
Updated 2017-12-05
This is documentation for the debug printing system found in game/scripts/vscripts/internal/util.lua.
Usage
DebugPrintcan be used pretty much the same way as normal Luaprint.DebugPrintTableis used for printing all keys in a given table. Does not expand nested tables. Keep in mind that files must be explicitly whitelisted to enable usage ofDebugPrintandDebugPrintTable. The process for whitelisting files is explained just below.
Enabling Printing
By default, files won't be allowed to print debug information using DebugPrint and DebugPrintTable. Printing can be enabled by calling Debug:EnableDebugging() in the file which you wish to enable printing for.
If more control is necessary, one can disable and enable printing by modifying the keys in the Debug.EnabledModules table. Setting a key to true will enable printing, while setting it to nil will disable it.
- The keys are strings of the filepaths to enable printing for, with : as the file separator.
- * can be used as the wildcard symbol, which will enable printing for all files in a folder and its subfolders.
game/scripts/vscriptsandgame/scripts/vscripts/componentsare both considered as root directories.
So for example, to enable printing for the file game/scripts/vscripts/components/abilities/level.lua, you would write Debug.EnabledModules['abilities:level'] = true into level.lua, or alternatively, you could enable printing for the whole abilities folder: Debug.EnabledModules['abilities:*'] = true (this also enables printing for files in game/scripts/vscripts/abilities).
Additional Debug Info
DebugPrint and DebugPrintTable automatically prepend the filepath and line number where they are called to assist in debugging.