Handy script to control console debug printing
Posted: Fri Jan 25, 2013 3:24 pm
As I'm drawing closer to finishing my dungeon, I realized I wanted to go through and turn off all the debug messages I used to work through the scripts.
I knew it would take a while to hunt them all down, and I knew I would still be making more of them while working on the last couple levels, so I set up the following script to handle it much more neatly:
script entity called pr
It can handle prints with up to four segments (I've only ever used two), such as:
pr.nt(my_table, variable1.." is not the way", suchTimer.x, suchTimer.y)
I've converted all my "print" to "pr.nt" by doing a big 'ol search and replace in the dungeon.lua, and voila, now it works great, and I can leave them on for the beta-testers and then just turn em off at public release time by editing "printON = true" to "printON = false"
I knew it would take a while to hunt them all down, and I knew I would still be making more of them while working on the last couple levels, so I set up the following script to handle it much more neatly:
script entity called pr
Code: Select all
printON = true
function nt(m1,m2,m3,m4)
if printON then
if m2 == nil and m3 == nil and m4 == nil then print(m1)
elseif m3 == nil and m4 == nil then print(m1,m2)
elseif m4 == nil then print(m1,m2,m3)
else print(m1,m2,m3,m4)
end
end
end
pr.nt("Debug texts are ON")
------------------------------------
-- this function and variable are for console printing. If
-- printON is true then all the console debug text will
-- print during play. Turn this to false before final release.
-- In scripts in the dungeon I might have a line like:
-- pr.nt("blah blah blah")pr.nt(my_table, variable1.." is not the way", suchTimer.x, suchTimer.y)
I've converted all my "print" to "pr.nt" by doing a big 'ol search and replace in the dungeon.lua, and voila, now it works great, and I can leave them on for the beta-testers and then just turn em off at public release time by editing "printON = true" to "printON = false"