debug echos

Share your scripts and packages with other Mudlet users.
Post Reply
Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

debug echos

Post by Caled »

Code: [show] | [select all] lua
if tools == nil then tools = {} end
if tools.debug == nil then tools.debug = {} end
if tools.debug.reporton == nil then tools.debug.reporton = {} end


function debugEcho(msg, script)
	local reporton = tools.debug.reporton
	if reporton[script] ~= nil 	then echo("\nDebug " .. script .. ": " .. msg .. "\n")
	elseif script == "all" 		then echo("\nDebug all: " .. msg .. "\n")
	end
end


Alias: Debug mode
^debug (\w+) (on|off)$
Script:
if matches[3] == "on" then avalanche.tools.debug.reporton[matches[2]] = true
else avalanche.tools.debug.reporton[matches[2]] = nil
end
In your scripts, put your test echos as follows:

debugEcho("canSalve beginning", "curing")

^ Just an example. Most of the debug echos for my curing system that I want to keep (since I am undoubtedly going to have bugs with it in the future) I give the debug label 'curing'.
Whenever I have a problem curing, I type: "debug curing on" and a bunch of useful debug echos will show next time I attempt to cure anything.

At the moment it is pretty primitive, but I decided to post this partly because I find it really useful, but also because I'm hoping someone else might have ideas on how to make it better. If you have a suggestion on how a debug system ought to be, please post and I'll probably make the changes.

Also, the function name could be better. It used to be decho() but I changed it when decho became claimed by Mudlet.

Post Reply