Debug.lua
| This is the archived page of the old LunaLua documentation The rest of LunaLua related articles in this wiki contain a lot of outdated documentation preserved for historical purposes and may be used with legacy versions of the LunaLua.
Please visit the SMBX2 Documentation Page to access the latest documentation for the LunaLua scripting system of the SMBX2 Project. Adding LunaLua contents into this Wiki is not advised. |
A small library allowing simple debugging of multiple types, including tables, of up to 30 lines. Values can be printed with or without a headings. Values are printed at the end of every tick to the top left of the screen and down the left side. In the future, this library will allow debugging with priority.
Download 1.2.1: http://hastebin.com/lajexociyo.lua
Installation
Place the file the text provided above in a file named debug.lua. Place debug.lua into the LuaScriptsLib folder.
How to use
To enable the Debug library for a specific level, add this line to lunadll.lua:
local debug = API.load("debug");
This will load the Debug API.
Example
local debug = API.load("debug");
local t = {1, [3] = 5, ["word"] = "string"};
local number = 73;
function onTick()
debug.table(t, "aTable");
debug.simple(number);
end
Should print:
aTable[1]: 1
aTable[3]: 5
aTable[word]: string
73
Functions
| type | object | heading |
|---|---|---|
| Prints the type of an object. | object | string: optional
Not required, but when not nil will print the string given by the second argument preceding the value. |
| simple | object | heading |
| Prints the values of an object, but only errors if it is not number, boolean, nil, or string type. | object | string: optional
Not required, but when not nil will print the string given by the second argument preceding the value. |
| table | table | heading |
| Prints out all indices of the table. | table | string: optional
Not required, but when not nil will print the string given by the second argument preceding the value. |