Simple debugging functions

Share your scripts and packages with other Mudlet users.
Post Reply
User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Simple debugging functions

Post by demonnic »

I honestly can't claim I created these, but I can't remember who it is gave them to me originally either. I do recall he told me I could distribute it about though, and it's been included in most of my packages (since I use it while writing them) for some time now. I thought it might be a good idea to go ahead and post it up though.

Three aliased commands are available:

debug: toggles debugging on and off
debug list: shows a list of all categories of debugging you are watching
debugc category: will add category to the list of watched debuggers. If it's already on the list, it will remove it. If no category is given, it behaves as "debug list" .

So for example if I am working on an autosipper, and am trying to debug it, I might do

debugc sipper
debug

To add the sipper category to the list of watched items, then toggle debug on. Then in my code, it may look something like this (replacing ... with relevant code):
Code: [show] | [select all] lua
if myHealthPerc < sipHealthPerc then
  demonnic:printDebug("sipper", "Uh oh, health is low. Time to sip!")
  ...
end
And it will print a debugging message to the main window when it passes that branch in the code. If you pass a string or a number, it will echo it to the main window. If you pass a table for the second parameter to printDebug, it will run it through display().

And that's pretty much it in a nutshell. Package is attached, let me know if you have any questions.
Attachments
Debug.zip
(1.15 KiB) Downloaded 425 times

Lezard
Posts: 36
Joined: Wed Aug 29, 2012 6:47 pm

Re: Simple debugging functions

Post by Lezard »

This will be very helpful :) thanks for sharing this, and thanks to whomever created it

User avatar
kevutian
Posts: 217
Joined: Fri Aug 20, 2010 8:18 pm
Location: United Kingdom
Contact:

Re: Simple debugging functions

Post by kevutian »

Yeah, I have been using these functions for years. Really useful.

Post Reply