remove draw_debug since it doesn't work; add "puke" debug helper

linked lists don't have a measurable length. will use a persistent intangible for debug dumps in the future. `puke` however can be used at the CLI to dump a table. I need to write a `listpuke` variant too
This commit is contained in:
Kistaro Windrider 2023-09-30 13:32:52 -07:00
parent da8a5b9589
commit f67c2da37f
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -9,8 +9,6 @@ game = 1
win = 2
lose = 3
debug = {}
function usplit(str)
return unpack(split(str))
end
@ -251,7 +249,6 @@ end
function _draw()
drawgame()
draw_debug()
if (state == game) fadelvl = -45
if (state == win) dropshadow("win",50,61,11)
if (state == lose) dropshadow("fail",48,61,8)
@ -291,21 +288,19 @@ function fadescreen()
end
end
function draw_debug()
cursor(0,0,7)
-- uncomment the followingh
-- to display object counts
--[[
print("es "..tostr(#eships))
print("eb "..tostr(#ebullets))
print("pb "..tostr(#pbullets))
print("ib "..tostr(#intangibles_bg))
print("if "..tostr(#intangibles_fg))
print("v "..tostr(#events))
]]
if (#debug==0) return
foreach(debug,print)
debug={}
function puke(item, indent)
indent = indent or 0
local pfx = ""
for _=1,indent do
pfx ..= " "
end
if (type(item) ~= "table") return pfx..tostr(item)
ret = pfx.."{"
pfx = "\n"..pfx
for k, v := pairs(item) do
ret ..= pfx..tostr(k)..": "..puke(v, indent+1)
end
return ret..pfx.."}"
end
function drawgame()