I'm coming from the Laravel world and there's a great helper function I use all the time called 'Die and Dump'. It's perfect for debugging and I've been missing it so I rewrote it for pico8.
Wherever you are in your code put dd($variable) and it will work out whether it's a number, string or table and print it all out in a tree and then stop() the process. Colour coded per level in the array.
edit fixed bug rendering a single string
P#72160 2020-01-22 05:17 ( Edited 2020-01-22 08:05)
:: ChristopherD
85-token version? (vs. 113 for original)
function dd(object)
indent = 0
cls(0)
print('start')
_dd(object)
print('end')
stop()
end
function _dd(object, key)
indent_text = sub(' ', -indent)
color(7+(indent\2))
if (type(object) != 'table') then
print(indent_text..key..': '..object)
else
if (key) print(indent_text..key)
indent+=2
for key, value in pairs(object) do
_dd(value, key)
end
indent-=2
end
end |
P#87528 2021-02-12 01:53
[Please log in to post a comment]



