/
CDC-1.2b/
CDC-1.2b/src/
parent $body
object $robot

var $root dbref 'robot
var $root child_index 0
var $root fertile 0
var $root manager $robot
var $root owned [$robot]
var $root owners [$robot]
var $root writable []
var $root readable ['parameters, 'methods, 'code]
var $named name ['uniq, "Robot"]
var $named name_aliases []
var $gendered gender $gender_neuter
var $has_verbs verbs #[]
var $described prose #[['short, "A giant hungry rat. His red eyes glare at you malevontly."]]
var $located location $body_cave
var $located obvious 1
var $root inited 1
var $robot tell_filters [["* says, \"<this>, list commands\"", 'commands]]
var $body body_parts #[]
var $location contents []
var $has_commands commands []
var $has_commands shortcuts []
var $old_command_environment verb_cache #[]
var $old_command_environment command_cache []
var $old_command_environment shortcuts_cache []

method tell
    arg text;
    var t, p;
    
    for t in (.tell_filters()) {
        p = t[1];
        p = strsub(p, "<this>", .namef());
        if (match_pattern(p, text))
            $scheduler.add_task(1, t[2], text);
    }
.

method add_tell_filter
    arg mask, method;
    
    .perms(sender());
    if ((type(mask) != 'string) || (type(method) != 'symbol))
        throw(~type, "Args must be a string and a symbol.");
    tell_filters = [@tell_filters, [mask, method]];
.

method del_tell_filter
    arg mask;
    var t, tf;
    
    .perms(sender());
    if (type(mask) != 'string)
        throw("Argument must be a string");
    tf = [];
    for t in [1 .. listlen(tell_filters)] {
        if (((tell_filters[t])[1]) == mask) {
            if (t > 1)
                tf = [@tf, @sublist(tell_filters, 1, t - 1)];
            if (t < listlen(tell_filters))
                tf = [@tf, @sublist(tell_filters, t + 1)];
            tell_filters = tf;
            return;
        }
    }
    throw(~tell_nf, "Mask not found.");
.

method tell_filters
    var t;
    
    catch ~methodnf {
        t = pass();
    } with handler {
        t = [];
    }
    return [@tell_filters, @t];
.

method good_morning
    arg text;
    
    text = $string.to_list(text, " ");
    .say("Good morning, " + (text[1]));
.

method say
    arg what;
    
    (.location()).announce((((.namef()) + " says, \"") + what) + "\"");
.

method commands
    arg text;
    var o, who, t;
    
    //"* says, \"<this>, list commands\""
    text = $string.to_list(text, " ");
    who = $object.to_dbref(text[1]);
    o = [(who.namef()) + ", my commands are:"];
    for t in (.tell_filters())
        o = [@o, (("  \"" + (t[1])) + "\" which calls ") + tostr(t[2])];
    .lsay(o);
.

method lsay
    arg what;
    
    what = [((.namef()) + " says, \"") + (what[1]), @sublist(what, 2)];
    (.location()).announce(what);
.

method follow
    arg who;
    
    if (type(who) == 'string)
        who = $object.to_dbref(who);
    if (type(who) != 'dbref)
        throw(~objnf, ("Object (" + who) + ") unknown.");
    following = who;
.

method event
    arg frob;
    
    if (class(frob) != $movement_event)
        return;
    (frob.exit()).go_through();
.