Debugging Tools | |
otlib | |
Vardump | Returns useful, readable information about variables. |
ThrowBadArg | “Throws” an error similar to the lua standard error of “bad argument #x to <fn_name> (<type> expected, got <type>)”. |
CheckArg | Used to check to see if a function argument matches what is expected. |
Vardump | Returns useful, readable information about variables. |
ThrowBadArg | “Throws” an error similar to the lua standard error of “bad argument #x to <fn_name> (<type> expected, got <type>)”. |
CheckArg | Used to check to see if a function argument matches what is expected. |
function Vardump( ... )
Returns useful, readable information about variables.
... | Accepts any number of parameters of any type and prints them one by one. |
A readable string serialization of the data passed in.
Vardump( { "foo", apple="green", floor=41, shopping={ "milk", "cookies" } } )
returns the string...
(table: array size=1, total values=4) 1 = "foo" "apple" = "green" "floor" = 41 "shopping" = (table: array size=2, total values=2) 1 = "milk" 2 = "cookies"
v1.00 | Initial. |
function ThrowBadArg( argnum, fn_name, expected, data, throw_level )
”Throws” an error similar to the lua standard error of “bad argument #x to <fn_name> (<type> expected, got <type>)”.
argnum | The optional argument number that was bad. |
fn_name | The optional string of the function name being called. |
expected | The optional string or list table of the type(s) you expected. |
data | Optional and any type, the actual data you got. |
throw_level | The optional number of how many levels up to throw the error. Defaults to 3. |
Never returns, throws an error.
v1.00 | Initial. |
function CheckArg( argnum, fn_name, expected, data, throw_level )
Used to check to see if a function argument matches what is expected. If it doesn’t, call ThrowBadArg. This function is primarily useful at the beginning of a function definition to ensure that the correct type of data was passed in.
argnum | The optional argument number that was bad. |
fn_name | The optional string of the function name being called. |
expected | The optional string or list table of the type(s) you expected. |
data | Optional and any type, the actual data you got. |
throw_level | The optional number of how many levels up to throw the error. Defaults to 4. |
Never returns if the data is bad since it throws an error. Otherwise returns true.
v1.00 | Initial. |
Returns useful, readable information about variables.
function Vardump( ... )
“Throws” an error similar to the lua standard error of “bad argument #x to fn_name (type expected, got type)”.
function ThrowBadArg( argnum, fn_name, expected, data, throw_level )
Used to check to see if a function argument matches what is expected.
function CheckArg( argnum, fn_name, expected, data, throw_level )
Counts the number of elements in a table using pairs.
function Count( t )