"A simple MOO trace utility"; "By Amy Bruckman and Albert Lin"; "MIT Media Lab"; "January 1994"; "See the included help message for more information."; "This file requires wizardly installation only in order to"; "modify system objects like $prog. You could also just"; "install it on your own character object."; @property $prog.traced {} r $hacker @verb $command_utils:trace_msg tnt rxd $hacker @program $command_utils:trace_msg "Syntax: trace_msg()"; "Prints the given message, if either the calling object or verb are on the"; "player's .traced property"; callers = callers(); caller_object = callers[1][1]; caller_verb = callers[1][2]; final_args = {}; if (caller_object in player.traced || caller_verb in player.traced) "Convert lists to printable form"; "It's better to do this here than nested in the call to trace_msg"; "Because it's expensive, and this way it doesn't get done if the"; "Function isn't traced"; for a in (args) if (typeof(a) == LIST) a = $string_utils:print(a); endif final_args = {@final_args, a}; endfor player:tell(caller_object, ":", caller_verb, ": ", @final_args); endif . @verb $prog:"@trace trace" any none none rxd $hacker @program $prog:@trace "Settor for .traced property. Written by Albert 1/10/94."; "Usage: @trace [object|string]. Adds object or verbname to .traced property."; " If no arguments, prints out current trace list."; if (player != this) return E_PERM; endif name = dobjstr; what = dobj; if (name) if (what == $ambiguous_match) player:tell("\"", who, "\" is ambiguous."); elseif (valid(what)) if (what in this.traced) player:tell("You are already tracing ", what.name, "."); else this.traced = {@this.traced, what}; player:tell(what.name, " added to trace list."); endif else if (name in this.traced) player:tell("You are already tracing \"", name, "\"."); else player:tell("\"", name, "\" added to trace list."); this.traced = {@this.traced, name}; endif endif endif tlist = {}; for t in (this.traced) if (typeof(t) == OBJ) tlist = {@tlist, $string_utils:nn(t)}; else tlist = {@tlist, "\"" + t + "\""}; endif endfor player:tell("Currently tracing: ", $string_utils:english_list(tlist), "."); . @verb $prog:"@untrace untrace" any none none rxd $hacker @program $prog:@untrace "Settor for .traced property. Written by Albert 1/10/94."; "Usage: @untrace ['all'|object|string]. Removes object or verbname from"; "traced property. @untrace all clears trace list."; name = dobjstr; what = dobj; if (name == "all") player:tell("Clearing tracelist."); this.traced = {}; return; endif if (what == $ambiguous_match) player:tell("\"", who, "\" is ambiguous."); return what; endif if (valid(what)) if (n = what in this.traced) this.traced = listdelete(this.traced, n); player:tell(what.name, " removed from trace list."); else player:tell("You are not tracing ", what.name, "."); endif else if (n = name in this.traced) this.traced = listdelete(this.traced, n); player:tell("\"", name, "\" removed from trace list."); else player:tell("You are not tracing \"", name, "\"."); endif endif tlist = {}; for t in (this.traced) if (typeof(t) == OBJ) tlist = {@tlist, t.name}; else tlist = {@tlist, "\"" + t + "\""}; endif endfor player:tell("Currently tracing: ", $string_utils:english_list(tlist), "."); . @property $prog_help."@trace" {} r ; !($prog_help.("@trace") = {"Syntax: @trace ", " @untrace ", " @untrace all", "", "If a function name is traced, then any call to to $command_utils:trace_msg", "within a verb of that name will generate a trace message. If an object is", "traced, then all functions on that object will be traced. Note that if there", "are no calls to $command_utils:trace_msg in a function, then tracing it will", "do nothing.", "", "Messages generated by $command_utils:trace_msg supply the object and function", "name, and can be given additional information to print out, with the same", "syntax as calls to the \"tell\" verb. In other words, if you are interested", "in seeing the value of a variable \"counter\", you might put in a trace", "message like:", "", "$command_utils:trace_msg(\"Counter: \", counter);", "", "If a list is supplied as an argument, it is automatically converted to", "printable form using $string_utils:print. ", ""}) @property $prog_help."@untrace" {"*forward*", "@trace"}