Root Class (#1)

(an instance of $nothing made by The_Mayor)

     



VERB SOURCE CODE:

initialize:
if (typeof(this.owner.owned_objects) == LIST)
    this.owner.owned_objects = setadd(this.owner.owned_objects, this);
endif
if ((caller == this) || $perm_utils:controls(caller_perms(), this))
    this.object_size = {0, 0};
    this.key = 0;
else
    return E_PERM;
endif
.


recycle:
if ((caller == this) || $perm_utils:controls(caller_perms(), this))
    if (typeof(this.owner.owned_objects) == LIST)
        this.owner.owned_objects = setremove(this.owner.owned_objects, this);
    endif
else
    return E_PERM;
endif
.


set_name:
"set_name(newname) attempts to change this.name to newname";
"  => E_PERM   if you don't own this or aren't its parent, or are a player trying 
to do an end-run around $player_db...";
if ((!caller_perms().wizard) && (is_player(this) || ((caller_perms() != this.owner) 
&& (this != caller))))
    return E_PERM;
else
    return (typeof(e = this.name = args[1]) != ERR) || e;
endif
.


title:
return this.name;
.


titlec:
return $object_utils:has_property(this, "namec") ? this.namec | $string_utils:capitalize(this:title());
.


set_aliases:
"set_aliases(alias_list) attempts to change this.aliases to alias_list";
"  => E_PERM   if you don't own this or aren't its parent";
"  => E_TYPE   if alias_list is not a list";
"  => E_INVARG if any element of alias_list is not a string";
if (!($perm_utils:controls(caller_perms(), this) || (this == caller)))
    return E_PERM;
elseif (typeof(aliases = args[1]) != LIST)
    return E_TYPE;
else
    for s in (aliases)
        if (typeof(s) != STR)
            return E_INVARG;
        endif
    endfor
    this.aliases = aliases;
    return 1;
endif
.


match:
c = this:contents();
return $string_utils:match(args[1], c, "name", c, "aliases");
.


match_object:
":match_object(string [,who])";
args[2..1] = {this};
return $string_utils:match_object(@args);
.


set_description:
"set_description(newdesc) attempts to change this.description to newdesc";
"  => E_PERM   if you don't own this or aren't its parent";
if (!($perm_utils:controls(caller_perms(), this) || (this == caller)))
    return E_PERM;
elseif (typeof(desc = args[1]) in {LIST, STR})
    this.description = desc;
    return 1;
else
    return E_TYPE;
endif
.


description:
return this.description;
.


look_self:
desc = this:description();
if (desc)
    player:tell_lines(desc);
else
    player:tell("You see nothing special.");
endif
.


exam*ine:
player:tell("The examine command has been renamed to @examine.  Please use @examine.");
.


notify:
if (is_player(this))
    notify(this, args[1]);
endif
.


tell:
this:notify(tostr(@args));
.


tell_lines:
lines = args[1];
if (typeof(lines) == LIST)
    for line in (lines)
        this:tell(line);
    endfor
else
    this:tell(lines);
endif
.


accept:
set_task_perms(caller_perms());
return this:acceptable(@args);
.


moveto:
set_task_perms(this.owner);
return move(this, args[1]);
.


eject eject_nice eject_basic:
"eject(victim) --- usable by the owner of this to remove victim from this.contents. 
 victim goes to its home if different from here, or $nothing or $player_start according 
as victim is a player.";
"eject_basic(victim) --- victim goes to $nothing or $player_start according as victim 
is a player; victim:moveto is not called.";
what = args[1];
nice = verb != "eject_basic";
perms = caller_perms();
if ((!perms.wizard) && (perms != this.owner))
    return E_PERM;
elseif ((!(what in this.contents)) || what.wizard)
    return 0;
endif
if (nice && ($object_utils:has_property(what, "home") && ((typeof(what.home) == OBJ) 
&& ((what.home != this) && (is_player(what) ? what.home:accept_for_abode(what) | 
what.home:acceptable(what))))))
    where = what.home;
else
    where = is_player(what) ? $player_start | $nothing;
endif
if (nice)
    fork (0)
        "...Some objects like to know they've been moved...";
        "... this is the best we can do.  Remember :moveto() may be broken.";
        what:moveto(where);
    endfork
endif
return move(what, where);
.


is_unlocked_for:
return (this.key == 0) || $lock_utils:eval_key(this.key, args[1]);
.


huh:
set_task_perms(valid(caller_perms()) ? caller_perms() | player);
$command_utils:do_huh(verb, args);
.


set_message:
":set_message(msg_name,new_value)";
"Does the actual dirty work of @ object is ";
"changing the raw value of the message msg_name to be new_value.";
"Both msg_name and new_value should be strings, though their interpretation is up 
to the object itself.";
" => error value (use E_PROPNF if msg_name isn't recognized)";
" => string error message if something else goes wrong.";
" => 1 (true non-string) if the message is successfully set";
" => 0 (false non-error) if the message is successfully `cleared'";
if (!((caller == this) || $perm_utils:controls(caller_perms(), this)))
    return E_PERM;
else
    return (this.(args[1] + "_msg") = args[2]) && 1;
endif
.


do_examine:
"do_examine(examiner)";
"the guts of examine";
"call a series of verbs and report their return values to the player";
who = args[1];
"if (caller == this || caller == who)";
if (caller == who)
    "set_task_perms();";
    who:notify_lines(this:examine_names(who) || {});
    "this:examine_names(who);";
    who:notify_lines(this:examine_owner(who) || {});
    "this:examine_owner(who);";
    who:notify_lines(this:examine_desc(who) || {});
    "this:examine_desc(who);";
    who:notify_lines(this:examine_key(who) || {});
    "this:examine_key(who);";
    who:notify_lines(this:examine_contents(who) || {});
    who:notify_lines(this:examine_verbs(who) || {});
else
    return E_PERM;
endif
.


examine_key:
"examine_key(examiner)";
"return a list of strings to be told to the player, indicating what the key on this 
type of object means, and what this object's key is set to.";
"the default will only tell the key to a wizard or this object's owner.";
who = args[1];
if (((caller == this) && $perm_utils:controls(who, this)) && (this.key != 0))
    return {tostr("Key:  ", $lock_utils:unparse_key(this.key))};
    "who:notify(tostr(\"Key:  \", $lock_utils:unparse_key(this.key)));";
endif
.


examine_names:
"examine_names(examiner)";
"Return a list of strings to be told to the player, indicating the name and aliases 
(and, by default, the object number) of this.";
return {tostr(this.name, " (aka ", $string_utils:english_list({tostr(this), @this.aliases}), 
")")};
.


examine_desc:
"examine_desc(who) - return the description, probably";
"who is the player examining";
"this should probably go away";
desc = this:description();
if (desc)
    if (typeof(desc) != LIST)
        desc = {desc};
    endif
    return desc;
else
    return {"(No description set.)"};
endif
.


examine_contents:
"examine_contents(examiner)";
"by default, calls :tell_contents.";
"Should probably go away.";
who = args[1];
"if (caller == this && $object_utils:has_verb(this, \"tell_contents\"))";
if (caller == this)
    this:tell_contents(this.contents, this.ctype);
endif
.


examine_verbs:
"Return a list of strings to be told to the player.  Standard format says \"Obvious 
verbs:\" followed by a series of lines explaining syntax for each usable verb.";
if (caller != this)
    return E_PERM;
endif
who = args[1];
name = dobjstr;
vrbs = {};
commands_ok = this:examine_commands_ok(who);
dull_classes = {$root_class, $room, $player, $prog, $builder};
what = this;
hidden_verbs = this:hidden_verbs(who);
while (what != $nothing)
    $command_utils:suspend_if_needed(0);
    if (!(what in dull_classes))
        for i in [0..length(verbs(what)) - 1]
            $command_utils:suspend_if_needed(0);
            info = verb_info(what, tostr(i));
            syntax = verb_args(what, tostr(i));
            if (this:examine_verb_ok(what, i, info, syntax, commands_ok, hidden_verbs))
                dobj = syntax[1];
                prep = syntax[2];
                iobj = syntax[3];
                if (syntax == {"any", "any", "any"})
                    prep = "none";
                endif
                if (prep != "none")
                    for x in ($string_utils:explode(prep, "/"))
                        if (length(x) <= length(prep))
                            prep = x;
                        endif
                    endfor
                endif
                "This is the correct way to handle verbs ending in *";
                vname = info[3];
                while (i = index(vname, "* "))
                    vname = tostr(vname[1..i - 1], "", vname[i + 1..length(vname)]);
                endwhile
                if (vname[i = length(vname)] == "*")
                    vname = vname[1..i - 1] + "";
                endif
                vname = strsub(vname, " ", "/");
                rest = "";
                if (prep != "none")
                    rest = " " + ((prep == "any") ? "" | prep);
                    if (iobj != "none")
                        rest = tostr(rest, " ", (iobj == "this") ? name | "");
                    endif
                endif
                if (dobj != "none")
                    rest = tostr(" ", (dobj == "this") ? name | "", rest);
                endif
                vrbs = setadd(vrbs, ("  " + vname) + rest);
            endif
        endfor
    endif
    what = parent(what);
endwhile
if ($code_utils:verb_or_property(this, "help_msg"))
    vrbs = {@vrbs, tostr("  help ", dobjstr)};
endif
return vrbs && {"Obvious verbs:", @vrbs};
.


get_message:
":get_message(msg_name)";
"Use this to obtain a given user-customizable message's raw value, i.e., the value 
prior to any pronoun-substitution or incorporation of any variant elements --- the 
value one needs to supply to :set_message().";
"=> error (use E_PROPNF if msg_name isn't recognized)";
"=> string or list-of-strings raw value";
"=> {2, @(list of {msg_name_n,rawvalue_n} pairs to give to :set_message)}";
"=> {1, other kind of raw value}";
"=> {E_NONE, error message} ";
if (!((caller == this) || $perm_utils:controls(caller_perms(), this)))
    return E_PERM;
elseif (((t = typeof(msg = this.(msgname = args[1] + "_msg"))) in {ERR, STR}) || 
((t == LIST) && (typeof(msg[1]) == STR)))
    return msg;
else
    return {1, msg};
endif
.


room_announce*_all_but:
this.location:(verb)(@args);
.


init_for_core:
if (caller_perms().wizard)
    vnum = 0;
    while (vnum <= (length(verbs(this)) - 1))
        $command_utils:suspend_if_needed(0);
        info = verb_info(this, tostr(vnum))[3];
        if (index(info, "(old)"))
            delete_verb(this, tostr(vnum));
        else
            vnum = vnum + 1;
        endif
    endwhile
endif
.


contents:
"Returns a list of the objects that are apparently inside this one.  Don't confuse 
this with .contents, which is a property kept consistent with .location by the server. 
 This verb should be used in `VR' situations, for instance when looking in a room, 
and does not necessarily have anything to do with the value of .contents (although 
the default implementation does).  `Non-VR' commands (like @contents) should look 
directly at .contents.";
return this.contents;
.


examine_verb_ok:
"examine_verb_ok(loc, index, info, syntax, commands_ok, hidden_verbs)";
"loc is the object that defines the verb; index is which verb on the object; info 
is verb_info; syntax is verb_args; commands_ok is determined by this:commands_ok, 
probably, but passed in so we don't have to calculate it for each verb.";
"hidden_verbs is passed in for the same reasons.  It should be a list, each of whose 
entries is either a string with the full verb name to be hidden (e.g., \"d*rop th*row\") 
or a list of the form {verb location, full verb name, args}.";
if ((caller == this) || $perm_utils:controls(caller_perms(), this))
    loc = args[1];
    info = args[3];
    vname = info[3];
    syntax = args[4];
    hidden_verbs = args[6];
    return (((((syntax[2..3] != {"none", "this"}) && (!index(vname, "("))) && (args[5] 
|| ("this" in syntax))) && verb_code(loc, tostr(args[2]))) && (!(vname in hidden_verbs))) 
&& (!({loc, vname, syntax} in hidden_verbs));
else
    return E_PERM;
endif
.


is_listening:
"return 1 if the object can hear a :tell, or cares. Useful for active objects that 
want to stop when nothing is listening.";
return 0;
.


hidden_verbs:
"hidden_verbs(who)";
"returns a list of verbs on this that should be hidden from examine";
"the player who's examining is passed in, so objects can hide verbs from specific 
players";
"verbs are returned as {location, full_verb_name, args} or just full_verb_name.  
full_verb name is what shows up in verb_info(object, verb)[2], for example \"d*op 
th*row\".";
if ((caller == this) || $perm_utils:controls(caller_perms(), this))
    hidden = {};
    what = this;
    while (what != $nothing)
        for i in [0..length(verbs(what)) - 1]
            info = verb_info(what, tostr(i));
            if (!index(info[2], "r"))
                hidden = setadd(hidden, {what, info[3], verb_args(what, tostr(i))});
            endif
        endfor
        what = parent(what);
    endwhile
    return hidden;
else
    return E_PERM;
endif
.


examine_owner:
"examine_owner(examiner)";
"Return a list of strings to be told to the player, indicating who owns this.";
return {tostr("Owned by ", this.owner.name, ".")};
.


announce*_all_but:
return;
.


tell_lines_suspended:
lines = args[1];
if (typeof(lines) == LIST)
    for line in (lines)
        this:tell(line);
        $command_utils:suspend_if_needed(0);
    endfor
else
    this:tell(lines);
endif
.


acceptable:
"intended as a 'quiet' way to determine if :accept will succeed. Currently, some 
objects have a noisy :accept verb since it is the only thing that a builtin move() 
call is guaranteed to call.";
"if you want to tell, before trying, whether :accept will fail, use :acceptable instead. 
Normally, they'll do the same thing.";
return 0;
.



PROPERTY DATA:
      key
      aliases
      description
      object_size

CHILDREN:
generic room The System Object generic thing generic player generic exit Mail Distribution Center Generic Mail Recipient Generic Gendered Object Generic Database Generic Help Database The Body Bag Generic BigList Resident Verb Help DB Guest Log Player Last_huh Verbs Login Commands Generic Option Package Error Generator Network Utilities Local Clearinghouse Generic Utilities Package bowl of milk @paranoid database generic tattoo Object #1994 Object #2010 sick utilities body part plain vanilla ass key lame test cigar Geek Code Millebornes database