(tree): Useful debugging predicate

I’m slowly building up additional debugging tools when developing using Dialog.

%% Like @tree, but rooted in current room, and shows relations and other details
(tree)
    (current room $Room)
    $Room 
    (if) (inherently dark $Room) (then) \(dark\) (endif)
    (line)
    (exhaust) {
        *($Obj has parent $Room)
        (tree contents $Obj 4)
    }

(tree contents $Obj $Indent)
    (space $Indent)
    ($Obj has relation $Rel)
    $Obj $Rel
    (if) ($Obj is handled) (then) \(handled\) (endif)
    (if) ($Obj provides light) (then) \(lit\) (endif)
    (line)
    ($Indent plus 4 into $ChildIndent)
    (exhaust) {
        *($Child has parent $Obj)
        (tree contents $Child $ChildIndent)
    }

This is somewhat like @tree, but is rooted in the current room, and shows additional details about each object.

Example:

> (tree)
#middle-of-nowhere (dark)
    #tower #in
    #sagebrush #in
    #desert-sand #in
    #tire-tracks #in
    #pickup-truck #in
        #knock #in (lit)
            #cigarettes #heldby (handled)
            #lighter #heldby (handled)
            #wallet #heldby (handled)
                #license #in
                #receipt #in
            #jacket #wornby
            #emotional-baggage #heldby (handled)
        #jade #in
        #headlights #partof
    #wiffs-of-gasoline #in
    #saguaro #in
Query succeeded: (tree)
> 
2 Likes