Random Features Maybe Useful (#1216)

(an instance of Generic Feature Object made by Random)

     Feature Object for Maybe Useful Stuff. All ported.
     At this point, @find #xxx works. The others have some weird stuff going on.

Go to location of this object, Random.



VERB SOURCE CODE:

@find:
"'@find #', '@find ', '@find :' '@find .' - Attempt 
to locate things. Verbs and properties are found on any object in the player's vicinity, 
and some other places.";
if (!dobjstr)
    player:tell("Usage: '@find #' or '@find ' or '@find :' 
or '@find .'.");
    return;
endif
if (dobjstr[1] == ":")
    name = dobjstr[2..length(dobjstr)];
    this:find_verb(name);
    return;
elseif (dobjstr[1] == ".")
    name = dobjstr[2..length(dobjstr)];
    this:find_property(name);
    return;
elseif (dobjstr[1] == "#")
    target = toobj(dobjstr);
    if (!valid(target))
        player:tell(target, " does not exist.");
    endif
else
    target = $string_utils:match_player(dobjstr);
    $command_utils:player_match_result(target, dobjstr);
endif
if (valid(target))
    player:tell(target.name, " (", target, ") is at ", valid(target.location) ? target.location.name 
| "Nowhere", " (", target.location, ").");
endif
.



find_verb:
"'find_verb ()' - Search for a verb with the given name. The objects searched 
are those returned by this:find_verbs_on(). The printing order relies on $list_utils:remove_duplicates 
to leave the *first* copy of each duplicated element in a list; for example, {1, 
2, 1} -> {1, 2}, not to {2, 1}.";
name = args[1];
results = "";
objects = $list_utils:remove_duplicates(this:find_verbs_on());
for thing in (objects)
    if (valid(thing) && (mom = $object_utils:has_verb(thing, name)))
        results = ((((results + "   ") + thing.name) + "(") + tostr(thing)) + ")";
        mom = mom[1];
        if (thing != mom)
            results = ((((results + "--") + mom.name) + "(") + tostr(mom)) + ")";
        endif
    endif
endfor
if (results)
    this:tell("The verb :", name, " is on", results);
else
    this:tell("The verb :", name, " is nowhere to be found.");
endif
.


find_property:
"'find_property ()' - Search for a property with the given name. The objects 
searched are those returned by this:find_properties_on(). The printing order relies 
on $list_utils:remove_duplicates to leave the *first* copy of each duplicated element 
in a list; for example, {1, 2, 1} -> {1, 2}, not to {2, 1}.";
name = args[1];
results = "";
objects = $list_utils:remove_duplicates(this:find_properties_on());
for thing in (objects)
    if (valid(thing) && (mom = $object_utils:has_property(thing, name)))
        results = ((((results + "   ") + thing.name) + "(") + tostr(thing)) + ")";
        mom = this:property_inherited_from(thing, name);
        if (thing != mom)
            if (valid(mom))
                results = ((((results + "--") + mom.name) + "(") + tostr(mom)) + 
")";
            else
                results = results + "--built-in";
            endif
        endif
    endif
endfor
if (results)
    this:tell("The property .", name, " is on", results);
else
    this:tell("The property .", name, " is nowhere to be found.");
endif
.


find_verbs_on:
"'find_verbs_on ()' -> list of objects - Return the objects that @find searches when 
looking for a verb. The objects are searched (and the results printed) in the order 
returned. Feature objects are included in the search. Duplicate entries are removed 
by the caller.";
return {this, this.location, @valid(this.location) ? this.location:contents() | {}, 
@this:contents(), @this.features};
.


find_properties_on:
"'find_properties_on ()' -> list of objects - Return the objects that @find searches 
when looking for a property. The objects are searched (and the results printed) in 
the order returned. Feature objects are *not* included in the search. Duplicate entries 
are removed by the caller.";
return {this, this.location, @valid(this.location) ? this.location:contents() | {}, 
@this:contents()};
.



PROPERTY DATA: