ID:138425
 
I'm not planning to release it until I've actually used it for a while, but I couldn't help but post about this...

Last night I had a debugging problem where I needed to just plain look at all the values in my zone object to see what was going wrong.

I didn't intend to do anything major, but two hours later I found I had created a complete hyper-linked object inspector, cleverly called "Deadron's Deft Debugger", and in only 95 lines of code.

Today I upped that a bit adding some nice interface stuff, but it's still pretty amazing that in Byond you can get this with just a few lines of code.

Here is what it does:

If you create the debugger and call debugger.ControlPanel(), it displays this in your browser:

Deadron's Deft Debugger


Pick an object to examine.

your area | all areas
your turf | turfs in view
you | mobs in view | all mobs
objs in view | all objs


When you click on any of these objects, you get either a list of objects or a listing of an object's variables and their values.

If a value is an object, list, or savefile, you can click on it to view what is inside it.

The class also lets you add any object to the list that shows up in the ControlPanel. In my case, all my games are run by a top-level object called GameController -- by putting that in there, I can literally navigate to any object or value in my game. Here is what the GameController looks like when I choose it:

GameController


name = GameController    [text]
_initialized = 1    [number]
version = 1    [text]
version_date = 8/12/00    [text]
gameDatabase = LivingDeadGame.sav    [savefile]
localDebugFile =     [null]
playerController = /deadron/dbitem/player_controller    [object]
gameForum = /deadron/dbitem/bbs/forum    [object]
clientList = /list    [list]
_eventReceivers =     [null]
bulletinboard = /ForumManager    [object]
isBroadcastingEvents = 0    [number]
lobby_zone = HQ    [object]
tag =     [null]
type = /game_controller    [object]
vars = /list    [list]


This is pretty incredible flexibility -- I certainly couldn't have created it in any other programming system I've used. It would have been way too complicated.

Once I've refined it based on my own debugging efforts, I'll release it. Over time I could add watchpoints and setting of values, if people find that interesting.

Dantom, a couple of questions:

1) Is there is a way for me to get my hands on the global vars hanging out there? That would be a nice addition...

2) Is there any way for me to determine that something is a type rather than an object? Right now a type looks like an object to me, and I make it hot, but actually clicking on it is not useful since it's not really an object.
On 8/26/00 6:14 pm Deadron wrote:

I didn't intend to do anything major, but two hours later I found I had created a complete hyper-linked object inspector, cleverly called "Deadron's Deft Debugger", and in only 95 lines of code.

Excellent! 95 lines is pretty impressive. Maybe we should hold one of those "who can write the coolest thing in the shortest amount of code" contests.

Dantom, a couple of questions:

1) Is there is a way for me to get my hands on the global vars hanging out there? That would be a nice addition...

Not right now, although we've discussed it in a different context (for saving the entire state of the world, including globals).

Somewhat off topic, but we should probably introduce a duality between var/proc and world.var/world.proc. The scope is identical, and this notation would allow world.vars[] to contain new globals.

2) Is there any way for me to determine that something is a type rather than an object? Right now a type looks like an object to me, and I make it hot, but actually clicking on it is not useful since it's not really an object.

If you know it is a type or an object, you can use isloc() to distinguish the two. Does that help?
In response to Tom H.
On 8/26/00 7:08 pm Tom H. wrote:
Excellent! 95 lines is pretty impressive. Maybe we should hold one of those "who can write the coolest thing in the shortest amount of code" contests.

I'm in. But who decides which is the coolest thing? I vote for celebrity judges.

Actually, you know, I bet when BYOND is rich and famous, you guys could hold a contest every year for exciting prizes, and generate great publicity. What fun!

Z
In response to Zilal
Actually, you know, I bet when BYOND is rich and famous, you guys could hold a contest every year for exciting prizes, and generate great publicity. What fun!

I'll submit a chat server that requires only two lines of code. :)

Sounds like the debugger is pretty neat! I'm envious. For some reason I've had "programmer's block" for the past week...
In response to Guy T.
On 8/26/00 8:29 pm Guy T. wrote:
For some reason I've had "programmer's block" for the past week...


Well I have so many balls in the air -- my game, the savefile tutorial, working on the next version of the Deadron library -- that when I get stuck on something I just put in an hour on one of the others.

Hopefully I will get at least one of these things done soon!
In response to Deadron
Well I have so many balls in the air -- my game, the savefile tutorial, working on the next version of the Deadron library -- that when I get stuck on something I just put in an hour on one of the others.

I've heard variations of this idea (small actions that accumulate over time) recommended for exercise, house cleaning, political activism, and probably a dozen other things that people intend to do but, by and large, don't. I guess I should actually try it! Especially considering what a "refactoring" advocate I've become... if I've had personal experience applying the idea in one realm of endeavor, it makes sense that I should extend it elsewhere. The main problem will be acquiring the habit -- simply remembering that it's important to do it daily.

Thanks for the idea!
In response to Deadron
Hopefully I will get at least one of these things done soon!

I'm certain there was a name for this... I can't quite remember, though... I think it was Spuzzum Syndrome or something? =)