From 8a192f87a22fe693eb4bf55d0d3d6b8a86787e1a Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sat, 31 Dec 2022 23:54:27 -0800 Subject: [PATCH] Code review feedback, debug mode --- chameleonic.p8 | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/chameleonic.p8 b/chameleonic.p8 index ac482ec..017e2e9 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -26,6 +26,13 @@ function music_off() menuitem(3, "music: off", music_on) end +function gsv(s) + local ret=split(s,"\n") + for i,v in ipairs(ret) do + ret[i] = type(v) == "string" and split(v,"`") or {v} end + return ret +end + mnames={} function names(root) local n=mnames[root] @@ -1728,13 +1735,6 @@ end -->8 --hint system -function gsv(s) - local ret=split(s,"\n") - for i,v in ipairs(ret) do - ret[i] = type(v) == "string" and split(v,"`") or {v} end - return ret -end - function rot13(s) local sord = pack(ord(s,1,#s)) for i,c in ipairs(sord) do @@ -1758,21 +1758,29 @@ function hints:init() for rec in all(h) do rec[4]=rot13(rec[4]) local lh = self[rec[1]] - if not lh then - lh = {rec} - self[rec[1]] = lh - else + if lh then add(lh,rec) + else + self[rec[1]] = {rec} end end menuitem(1,"get hint",function() level.hintlevel+=1 end) menuitem(2,"hide hints",function() level.hintlevel=0 end) + -- debug mode: enable mouse + poke(0x5f2d,1) end hintflicker={7,10,9,8,8,9,10,7} function hints:draw2() pal() local c=hintflicker[t()%1*#hintflicker\1+1] + -- debug mode: mouse coord display + if stat(34) != 0 then + local mousex, mousey = stat(32), stat(33) + print("x ("..mousex..", "..mousey..")",mousex,mousey,c) + end + + for i,h in ipairs(self[level.ix]) do if (i > level.hintlevel) return local _,x,y,txt=unpack(h)