b8d @verb #13:"@which" any any any rdo #789 @program #13:"@which" any any any "Copied from Generic Programmer (#14):@which by Dax (#789)Nov 27 12:55:07 2001" "Finds the location of the specified command" "Looks through the player, the room, dobj, iobj and the player's features." if (!argstr) player:tell("Finds the location of the specified command.") player:tell("Usage: ", verb, " <command>") return endif debug = 0 {vname, d, p, i, a, @junk} = $string_utils:parse_command(argstr) {dobj, dobjstr} = d {prep, prepstr} = p {iobj, iobjstr} = i prepstr = $code_utils:full_prep(prepstr) || "none" iobj = player:my_match_object(iobjstr) player:tell("Searching for command named '", vname, "' with ", a[2] ? tostr("arguments '", a[2], "'") | "no arguments", "...") searchlist = {player, @player:ancestors(), player.location, @player.location:ancestors()} if (valid(dobj)) searchlist = {@searchlist, dobj, @dobj:ancestors()} endif if (valid(iobj)) searchlist = {@searchlist, iobj, @iobj:ancestors()} endif for o in (searchlist) "switch 'this' every time we change object classes" if (o == player) this = player elseif (o == player.location) this = player.location elseif (o == dobj) this = dobj elseif (o == iobj) this = iobj endif debug && player:tell("... ", o:nn(), "...") n = 0 $command_utils:suspend_if_needed() while (n != -1) n = $code_utils:find_verb_named(o, vname, n + 1) if (n != -1) debug && player:tell("... :", n, "...") {o_d, o_p, o_i} = verb_args(o, n) if (o_p == "none" && o_i != "none") "Not a command verb." elseif (o_d == "none" && dobjstr || (o_i == "none" && iobjstr)) "Arguments where there shouldn't be any." elseif (o_p != prepstr && o_p != "any") "Preposition doens't match." elseif (o_d == "this" && dobj != this || (o_i == "this" && iobj != this)) "Argument doesn't match 'this'." else player:tell("...", o:nn(), ":", verbs(o)[n], " (", o_d, " ", o_p, " ", o_i, ")") return endif endif endwhile endfor player:tell("...checking feature list...") plist = {"any", prepstr} dlist = dobjstr ? {"any"} | {"none", "any"} ilist = iobjstr ? {"any"} | {"none", "any"} for o in (player.features) debug && $recycler:valid(o) && player:tell("... ", o:nn(), "...") $command_utils:suspend_if_needed() if (!$recycler:valid(o)) continue elseif ((loc = o:has_callable_verb(vname)) && valid(loc = loc[1])) debug && player:tell("... :", loc, "...") vargs = verb_args(loc, vname) if (vargs[2] in plist && (vargs[1] in dlist && vargs[3] in ilist)) player:tell("...", loc:nn(), ":", vname, " (", vargs[1], " ", vargs[2], " ", vargs[3], ")") return endif endif endfor player:tell("...command not found.") "Last modified by Dax (#789) on Mon Dec 10 21:01:11 2001 MST." . 0