matching utilities #44

Parent #72Owner #29Flags readSource hellcore/hellcore.db

Aliases: matching utilities

14 verbs · 17 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
matchthis none thisrxd#4432
match_nththis none thisrxd#4466
match_verbthis none thisrxd#4411
match_listthis none thisrxd#4418
parse_ordinal_reference parse_ordrefthis none thisrxd#4427
parse_possessive_referencethis none thisrxd#4419
object_match_failedthis none thisrx#4434
init_for_corethis none thisrxd#444
match_ambiguousthis none thisrxd#4436
match_manythis none thisrxd#4480
match_bodyrefthis none thisrxd#4422
parse_ordinal_reference_spunky_backupthis none thisrxd#4416
match_genericsthis none thisrxd#4437
match_objlist_propthis none thisrxd#449

Properties

PropertyDefinerFlagsOwnerValue
ordn#44rc#29
list of 99{"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth", "twentyfirst", "twentysecond", "twentythird", "twentyfourth", "twentyfifth", "twentysixth", "twentyseventh", "twentyeighth", "twentyninth", "thirtieth", "thirtyfirst", "thirtysecond", "thirtythird", "thirtyfourth", "thirtyfifth", "thirtysixth", "thirtyseventh", "thirtyeighth", "thirtyninth", "fortieth", "fortyfirst", "fortysecond", "fortythird", "fortyfourth", "fortyfifth", "fortysixth", "fortyseventh", "fortyeighth", "fortyninth", "fiftieth", "fiftyfirst", "fiftysecond", "fiftythird", "fiftyfourth", "fiftyfifth", "fiftysixth", "fiftyseventh", "fiftyeighth", "fiftyninth", "sixtieth", "sixtyfirst", "sixtysecond", "sixtythird", "sixtyfourth", "sixtyfifth", "sixtysixth", "sixtyseventh", "sixtyeighth", "sixtyninth", "seventieth", "seventyfirst", "seventysecond", "seventythird", "seventyfourth", "seventyfifth", "seventysixth", "seventyseventh", "seventyeighth", "seventyninth", "eightieth", "eightyfirst", "eightysecond", "eightythird", "eightyfourth", "eightyfifth", "eightysixth", "eightyseventh", "eightyeighth", "eightyninth", "ninetieth", "ninetyfirst", "ninetysecond", "ninetythird", "ninetyfourth", "ninetyfifth", "ninetysixth", "ninetyseventh", "ninetyeighth", "ninetyninth"}
ordw#44rc#29
list of 50{"1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th", "21st", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th", "31st", "32nd", "33rd", "34th", "35th", "36th", "37th", "38th", "39th", "40th", "41st", "42nd", "43rd", "44th", "45th", "46th", "47th", "48th", "49th", "50th"}
ordinal_regexp#44rc#29"%<%(1[0-9]th%|[2-9]*%(1st%|2nd%|3rd%|[04-9]th%)%|tenth%|eleventh%|twelfth%|thirteenth%|fourteenth%|fifteenth%|sixteenth%|seventeenth%|eighteenth%|nineteenth%|twentieth%|thirtieth%|fortieth%|fiftieth%|sixtieth%|seventieth%|eightieth%|ninetieth%|%(twenty%|thirty%|forty%|fifty%|sixty%|seventy%|eighty%|ninety%)?%(first%|second%|third%|fourth%|fifth%|sixth%|seventh%|eighth%|ninth%)%)%>"
matching_room#44r#29#-1
ordinal_regexp_old#44rc#29"%<%(first%|second%|third%|fourth%|fifth%|sixth%|seventh%|eighth%|ninth%|tenth%|eleventh%|twelfth%|thirteenth%|fourteenth%|fifteenth%|sixteenth%|seventeenth%|eighteenth%|nineteenth%|twentieth%|twentyfirst%|twentysecond%|twentythird%|twentyfourth%|twentyfifth%|twentysixth%|twentyseventh%|twentyeighth%|twentyninth%|thirtieth%|thirtyfirst%|thirtysecond%|thirtythird%|thirtyfourth%|thirtyfifth%|thirtysixth%|thirtyseventh%|thirtyeighth%|thirtyninth%|fortieth%|fortyfirst%|fortysecond%|fortythird%|fortyfourth%|fortyfifth%|fortysixth%|fortyseventh%|fortyeighth%|fortyninth%|fiftieth%|1st%|2nd%|3rd%|4th%|5th%|6th%|7th%|8th%|9th%|10th%|11th%|12th%|13th%|14th%|15th%|16th%|17th%|18th%|19th%|20th%|21st%|22nd%|23rd%|24th%|25th%|26th%|27th%|28th%|29th%|30th%|31st%|32nd%|33rd%|34th%|35th%|36th%|37th%|38th%|39th%|40th%|41st%|42nd%|43rd%|44th%|45th%|46th%|47th%|48th%|49th%|50th%)%>"
ordn_old#44rc#29
list of 50{"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth", "twentyfirst", "twentysecond", "twentythird", "twentyfourth", "twentyfifth", "twentysixth", "twentyseventh", "twentyeighth", "twentyninth", "thirtieth", "thirtyfirst", "thirtysecond", "thirtythird", "thirtyfourth", "thirtyfifth", "thirtysixth", "thirtyseventh", "thirtyeighth", "thirtyninth", "fortieth", "fortyfirst", "fortysecond", "fortythird", "fortyfourth", "fortyfifth", "fortysixth", "fortyseventh", "fortyeighth", "fortyninth", "fiftieth"}
help_msg#72rc#29
list of 16{"*** NOTE: for more help on any verb, do 'help $mu:verbname'.", "", "$match_utils ($mu) helps select objects from lists, by matching strings.", "", " Usually what you want:", ":match (str, obj-list) => object in list matching str", ":match_many (str, obj-list) => all objs in list matching str", ":match_bodyref (str, creature-list) => {creature, bodypart-obj}", "", " Usually not what you want:", ":match_nth (str, obj-list, n)=> nth object in list matching str", ":match_verb (verbname, obj) => use prepstr etc to find verb on obj", ":parse_ordinal_reference (\"fifth gun\") => {5, \"gun\"}", ":parse_possessive_reference(\"bob's gun\") => {\"bob\", \"gun\"}", ":object_match_failed (failedmatch, string [,ambigs])", " => Tell player why their object match failed."}
aliases#1rc#29{"matching utilities"}
description#1rc#29<clear>
object_size#1r#29{22977, 1298433815}
hidden_verbs#1rc#29<clear>
phelp_msg#1rc#29<clear>
weight#1rc#29<clear>
owner_verbs#1rc#29<clear>
plural_name#1rc#29<clear>
client_image#1rc#29<clear>
listening#1rc#29<clear>

Ancestry

Ancestors (nearest first): #72 Generic Utilities Package#1 root

Children: none

Call graph

calls n44_0 #44:match n20_16 #20:literal_object n44_0->n20_16 n20_76 #20:match_aliases n44_0->n20_76 n44_4 #44:parse_ordinal_reference n44_0->n44_4 n44_1 #44:match_nth n44_0->n44_1 n6_180 #6:systell n44_1->n6_180 n20_1 #20:left n44_1->n20_1 n44_2 #44:match_verb n45_2 #45:has_verb n44_2->n45_2 n44_6 #44:object_match_failed n42_0 #42:controls n44_6->n42_0 n51_2 #51:toobj n44_6->n51_2 n44_3 #44:match_list n44_6->n44_3 n47_7 #47:remove_duplicates n44_6->n47_7 n45_5 #45:isa n44_6->n45_5 n20_6 #20:english_list n44_6->n20_6 n44_7 #44:init_for_core n1_22 #1:init_for_core n44_7->n1_22 n44_8 #44:match_ambiguous n44_8->n44_0 n44_8->n20_16 n44_8->n44_4 n44_8->n44_1 n20_78 #20:match_aliases_ambiguous n44_8->n20_78 n44_5 #44:parse_possessive_reference n44_8->n44_5 n44_9 #44:match_many n44_9->n44_0 n254_8 #254:is_a n44_9->n254_8 n254_6 #254:group_by_type n44_9->n254_6 n44_10 #44:match_bodyref n44_10->n44_0 n44_12 #44:match_generics n44_12->n44_0 n44_12->n20_16 n44_12->n44_4 n44_12->n44_1 n44_12->n44_5 n20_133 #20:match_aliases_generics n44_12->n20_133

Source

match

Spec this none thisFlags rxdOwner #29Definer #44

Referenced by

Source

1":match(string, object-list)";
2"Return object in 'object-list' aliased to 'string'.";
3"Matches on a wide variety of syntax, including:";
4" \"5th axe\" -- The fifth object matching \"axe\" in the object list.";
5" \"where's sai\" -- The only object contained in 'where' matching \"sai\" (possible $ambiguous_match).";
6" \"where's second staff\" -- The second object contained in 'where' matching \"staff\".";
7" \"my third dagger\" -- The third object in your inventory matching \"dagger\".";
8"Ordinal matches are determined according to the match's position in 'object-list' or, if a possessive (such as \"where\" above) is given, then the ordinal is the nth match in that object's inventory.";
9"In the matching room (#3879@LambdaMOO), the 'object-list' consists of first the player's contents, then the room's, and finally all exits leading from the room.";
10{string, olist, ?silent = 0, ?who = player} = args;
11if (!string)
12return $nothing;
13elseif ((string == "me") && ((who in olist) || who.programmer))
14return who;
15elseif ((string == "here") && ((who.location in olist) || who.programmer))
16return who.location;
17elseif (who.programmer && valid(object = $string_utils:literal_object(string)))
18return object;
19elseif (valid(object = $su:match_aliases(string, olist, who)))
20return object;
21elseif (parsed = this:parse_ordinal_reference(string))
22return this:match_nth(parsed[2], olist, parsed[1], who, silent);
23"elseif (parsed = this:parse_possessive_reference(string))";
24"  {whostr, objstr} = parsed;";
25"  if (valid(whose = this:match(whostr, olist)))";
26"    return this:match(objstr, whose.contents);";
27"  else";
28"    return whose;";
29"  endif";
30else
31return object;
32endif

match_nth

Spec this none thisFlags rxdOwner #361Definer #44

Referenced by

Source

1":match_nth(string, objlist, n [, who])";
2"Find the nth object in 'objlist' that matches 'string'. Use who's private aliases if provided.";
3{subj, olist, n, ?who = #-1, ?silent = 0} = args;
4if ((valid(who) && is_a(who, $player)) && has_property(who, "private_aliases"))
5matchlist = (subj in who.private_aliases) ? who.private_aliases[subj] | {};
6for m in (matchlist)
7for o in (olist)
8if ((o == m) || is_a(o, m))
9if (!(n = n - 1))
10return o;
11endif
12endif
13yield 0;
14endfor
15yield 0;
16endfor
17endif
18"We have to check first for a fully specified alias.";
19n1 = n;
20exact_match = {};
21for o in (olist)
22if (subj in o.aliases)
23exact_match = {@exact_match, o};
24if (!(n1 = n1 - 1))
25return o;
26endif
27endif
28endfor
29if (0)
30if (exact_match && (!silent))
31player:systell($su:left(("Exact matches for '" + subj) + "'...", -45));
32i = 1;
33for x in (exact_match)
34player:systell("  ", i, ". ", $su:left(x.name, -40));
35i = i + 1;
36endfor
37return $failed_match;
38endif
39endif
40n2 = n;
41partial_match = {};
42for o in (olist)
43for alias in (o.aliases)
44if (index(alias, subj) == 1)
45partial_match = {@partial_match, o};
46if (!(n2 = n2 - 1))
47return o;
48else
49break;
50endif
51endif
52endfor
53endfor
54if (0)
55if (partial_match && (!silent))
56player:systell($su:left(("Partial matches for '" + subj) + "'...", -45));
57i = 1;
58for x in (partial_match)
59player:systell("  ", i, ". ", $su:left(x.name, -40));
60i = i + 1;
61endfor
62elseif (!silent)
63player:systell(("Nothing matched '" + subj) + "' at all.");
64endif
65endif
66return $failed_match;

match_verb

Spec this none thisFlags rxdOwner #361Definer #44

Referenced by

Source

1"$match_utils:match_verb(verbname, object) => Looks for a command-line style verb named <verbname> on <object> with current values of prepstr, dobjstr, dobj, iobjstr, and iobj.  If a match is made, the verb is called with @args[3] as arguments and 1 is returned.  Otherwise, 0 is returned.";
2{vrb, what, rest} = args;
3if (where = $object_utils:has_verb(what, vrb))
4if ((vargs = verb_args(where[1], vrb)) != {"this", "none", "this"})
5if (((((((vargs[2] == "any") || ((!prepstr) && (vargs[2] == "none"))) || index(("/" + vargs[2]) + "/", ("/" + prepstr) + "/")) && (((vargs[1] == "any") || ((!dobjstr) && (vargs[1] == "none"))) || ((dobj == what) && (vargs[1] == "this")))) && (((vargs[3] == "any") || ((!iobjstr) && (vargs[3] == "none"))) || ((iobj == what) && (vargs[3] == "this")))) && index(verb_info(where[1], vrb)[2], "x")) && verb_code(where[1], vrb))
6set_task_perms(caller_perms());
7what:(vrb)(@rest);
8return 1;
9endif
10endif
11endif

match_list

Spec this none thisFlags rxdOwner #29Definer #44

Referenced by

Source

1":match_list(string, object_list) -> List of all matches.";
2{what, where} = args;
3if (!what)
4return {};
5endif
6r = {};
7for v in (where)
8if (!(v in r))
9z = 0;
10for q in (v.aliases)
11z = z || (q && (index(q, what) == 1));
12endfor
13if (z)
14r = listappend(r, v);
15endif
16endif
17endfor
18return r;

parse_ordinal_reference parse_ordref

Spec this none thisFlags rxdOwner #29Definer #44

Referenced by

Source

1"Copied from Santates (#290421):parse_ordinal_reference Mon Dec 22 02:53:41 2008 CST";
2"Copied from matching utilities (#51):parse_ordinal_reference by Hacker (#36) Mon Dec  8 17:15:49 2008 CST";
3":parse_ordref(string)";
4"Parses strings referring to an 'nth' object.";
5"=> {INT n, STR object} Where 'n' is the number the ordinal represents, and 'object' is the rest of the string.";
6"=> 0 If the given string is not an ordinal reference.";
7"  Example:";
8":parse_ordref(\"second broadsword\") => {2, \"broadsword\"}";
9":parse_ordref(\"second\") => 0";
10"  Note that there must be more to the string than the ordinal alone.";
11text = args[1];
12if (m = match(text, ("^" + this.ordinal_regexp) + " +%([^ ].+%)$"))
13ordinal = substitute("%1", m);
14item = substitute("%5", m);
15if (om = match(ordinal, "%([0-9]+%)"))
16n = toint(substitute("%1", om));
17else
18n = ordinal in this.ordn;
19endif
20return n && {n, item};
21elseif (((periodloc = index(text, ".")) && (n = toint(text[1..periodloc - 1]))) && (length(text) > periodloc))
22return {n, text[periodloc + 1..$]};
23elseif (((length(text) > 2) && (n = toint(text[1]))) && (text[2] == "."))
24return {n, text[3..$]};
25else
26return 0;
27endif

parse_possessive_reference

Spec this none thisFlags rxdOwner #29Definer #44

Referenced by

Source

1":parse_possessive_reference(string)";
2"Parses strings in a possessive format.";
3"=> {STR whose, STR object}  Where 'whose' is the possessor of 'object'.";
4"If the string consists only of a possessive string (ie: \"my\", or \"yduJ's\"), then 'object' will be an empty string.";
5"=> 0 If the given string is not a possessive reference.";
6"  Example:";
7":parse_possessive_reference(\"joe's cat\") => {\"joe\", \"cat\"}";
8":parse_possessive_reference(\"sis' fish\") => {\"sis\", \"fish\"}";
9"  Strings are returned as a value suitable for a :match routine, thus 'my' becoming 'me'.";
10":parse_possessive_reference(\"my dog\") => {\"me\", \"dog\"}";
11string = args[1];
12if (m = match(string, "^my$%|^my +%(.+%)?"))
13return {"me", substitute("%1", m)};
14elseif (m = match(string, "^%(.+s?%)'s? *%(.+%)?"))
15return {substitute("%1", m), substitute("%2", m)};
16else
17return 0;
18endif
19"Profane (#30788) - Sun Jun 21, 1998 - changed first parenthetical match bit from %([^ ]+s?%) to %(.+s?%)";

object_match_failed

Spec this none thisFlags rxOwner #29Definer #44

Referenced by

Source

1"Usage: object_match_failed(object, string[, ambigs])";
2"Prints a message if string does not match object.  Generally used after object is derived from a :match_object(string).";
3"ambigs is an optional list of the objects that were matched upon.  If given, the message printed will list the ambiguous among them as choices.";
4{match_result, string, ?ambigs = 0} = args;
5tell = (0 && $perm_utils:controls(caller_perms(), player)) ? "notify" | "tell";
6if ((index(string, "#") == 1) && ($code_utils:toobj(string) != E_TYPE))
7"...avoid the `I don't know which `#-2' you mean' message...";
8if (!valid(match_result))
9player:(tell)(tostr("There is no \"", string, "\" that you can see."));
10endif
11return !valid(match_result);
12elseif (match_result == $nothing)
13player:(tell)("You must give the name of some object.");
14elseif (match_result == $failed_match)
15player:(tell)(tostr("There is no \"", string, "\" that you can see."));
16elseif (match_result == $ambiguous_match)
17if (typeof(ambigs) != LIST)
18player:(tell)(tostr("I don't know which \"", string, "\" you mean."));
19return 1;
20endif
21ambigs = $match_utils:match_list(string, ambigs);
22ambigs = $list_utils:map_property(ambigs, "name");
23if ((length($list_utils:remove_duplicates(ambigs)) == 1) && $object_utils:isa(player.location, this.matching_room))
24player:(tell)(tostr("I don't know which \"", string, "\" you mean.  Try using \"first ", string, "\", \"second ", string, "\", etc."));
25else
26player:(tell)(tostr("I don't know which \"", string, "\" you mean: ", $string_utils:english_list(ambigs, "nothing", " or "), "."));
27endif
28return 1;
29elseif (!valid(match_result))
30player:(tell)(tostr("The object you specified does not exist.  Seeing ghosts?"));
31else
32return 0;
33endif
34return 1;

init_for_core

Spec this none thisFlags rxdOwner #361Definer #44

Referenced by

none

Source

1if (caller_perms().wizard)
2pass();
3this.matching_room = $nothing;
4endif

match_ambiguous

Spec this none thisFlags rxdOwner #29Definer #44

Referenced by

Source

1":match_ambiguous(string, object-list)";
2"Return object in 'object-list' aliased to 'string'.";
3"Matches on a wide variety of syntax, including:";
4" \"5th axe\" -- The fifth object matching \"axe\" in the object list.";
5" \"where's sai\" -- The only object contained in 'where' matching \"sai\" (possible $ambiguous_match).";
6" \"where's second staff\" -- The second object contained in 'where' matching \"staff\".";
7" \"my third dagger\" -- The third object in your inventory matching \"dagger\".";
8"Ordinal matches are determined according to the match's position in 'object-list' or, if a possessive (such as \"where\" above) is given, then the ordinal is the nth match in that object's inventory.";
9"In the matching room (#3879@LambdaMOO), the 'object-list' consists of first the player's contents, then the room's, and finally all exits leading from the room.";
10{string, olist} = args;
11if (!string)
12return $nothing;
13elseif (string == "me")
14return player;
15elseif (string == "here")
16return player.location;
17elseif (player.programmer && valid(object = $string_utils:literal_object(string)))
18return object;
19endif
20object = $su:match_aliases_ambiguous(string, olist);
21if (valid(object))
22return object;
23elseif (object == $ambiguous_match)
24return $ambiguous_match;
25elseif (parsed = this:parse_ordinal_reference(string))
26return this:match_nth(parsed[2], olist, parsed[1]);
27elseif (parsed = this:parse_possessive_reference(string))
28{whostr, objstr} = parsed;
29if (valid(whose = this:match(whostr, olist)))
30return this:match(objstr, whose.contents);
31else
32return whose;
33endif
34else
35return object;
36endif

match_many

Spec this none thisFlags rxdOwner #361Definer #44

Referenced by

Source

1":match_many(STR name, LIST objects_to_match) => This verb will return a list of objects from objects_to_match that match the string given by 'name'.";
2{string, objs, ?who = #-1} = args;
3matchall = 0;
4maxmatches = $maxint;
5"Strip out 'all' if it appears at the beginning of the line";
6if ((matchspec = match(string, "^all ")) || (matchspec = match(string, "^all$")))
7matchall = 1;
8if (length(string) > 4)
9string = string[5..$];
10else
11string = "";
12endif
13endif
14"Look for a number, and if we find it try to match that many";
15if (matchspec = match(string, "^[0-9]+ "))
16matchall = 1;
17maxmatches = toint(string[matchspec[1]..matchspec[2]]);
18if (length(string) > matchspec[2])
19string = string[matchspec[2] + 1..$];
20else
21string = "";
22endif
23endif
24matches = {};
25if (matchall)
26"Find out if this matches any item types.";
27matchtype = 0;
28for t in [1..length($iu.matches)]
29if (string in $iu.matches[t])
30matchtype = t;
31matchall = 1;
32string = "";
33break;
34endif
35endfor
36if (matchtype)
37newobjs = {};
38for o in (objs)
39if ($iu:is_a(o, matchtype))
40newobjs = {@newobjs, o};
41endif
42endfor
43objs = newobjs;
44elseif ((string == "misc") && (length(newobjs = $iu:group_by_type(objs)[$]) > 0))
45objs = newobjs;
46string = "";
47elseif (valid(who) && is_a(who, $player))
48"Maybe it's a tag.";
49if (string in who.private_aliases)
50tagobjs = who.private_aliases[string];
51string = "";
52newobjs = {};
53for tobj in (tagobjs)
54for o in (objs)
55if ((o == tobj) || is_a(o, tobj))
56newobjs = {@newobjs, o};
57endif
58endfor
59yield;
60endfor
61objs = newobjs;
62endif
63endif
64"Now try to match each object in the object list";
65for x in (objs)
66if (length(matches) >= maxmatches)
67break;
68endif
69if ((!string) || valid(x:match(string)))
70matches = listappend(matches, x);
71endif
72endfor
73return matches;
74else
75if (valid(target = this:match(string, objs)))
76return {target};
77else
78return {};
79endif
80endif

match_bodyref

Spec this none thisFlags rxdOwner #361Definer #44

Referenced by

Source

1":match_bodyref(STR string, LIST creatures) => Match 'gilmore's face' against list of creatures.  Return {OBJ creature, OBJ bodypart}.";
2string = args[1];
3creatures = args[2];
4if (i = index(string, "'s "))
5bodypart = string[i + 3..$];
6string = string[1..i - 1];
7elseif (((length(string) > 3) && (string[1..3] == "my ")) && (player in creatures))
8bodypart = string[4..$];
9string = player.name;
10else
11bodypart = "";
12endif
13who = $mu:match(string, creatures);
14if (!valid(who))
15return {#-1, #-1};
16elseif (!is_a(who, $creature))
17return {who, #-1};
18elseif (!valid(bodypart = $mu:match(bodypart, who.body_parts)))
19return {who, #-1};
20else
21return {who, bodypart};
22endif

parse_ordinal_reference_spunky_backup

Spec this none thisFlags rxdOwner #29Definer #44

Referenced by

none

Source

1"Copied from matching utilities (#51):parse_ordinal_reference by Hacker (#36) Mon Dec  8 19:17:25 2008 CST";
2":parse_ordref(string)";
3"Parses strings referring to an 'nth' object.";
4"=> {INT n, STR object} Where 'n' is the number the ordinal represents, and 'object' is the rest of the string.";
5"=> 0 If the given string is not an ordinal reference.";
6"  Example:";
7":parse_ordref(\"second broadsword\") => {2, \"broadsword\"}";
8":parse_ordref(\"second\") => 0";
9"  Note that there must be more to the string than the ordinal alone.";
10if (m = match(args[1], ("^" + this.ordinal_regexp) + " +%([^ ].+%)$"))
11o = substitute("%1", m);
12n = (o in this.ordn) || (o in this.ordw);
13return n && {n, substitute("%2", m)};
14else
15return 0;
16endif

match_generics

Spec this none thisFlags rxdOwner #29Definer #44

Referenced by

none

Source

1"Copied from matching utilities (#51):match_ambiguous by Hacker (#36) Sun Nov 21 05:29:53 2010 CST";
2":match_ambiguous(string, object-list)";
3"Return object in 'object-list' aliased to 'string'.";
4"Matches on a wide variety of syntax, including:";
5" \"5th axe\" -- The fifth object matching \"axe\" in the object list.";
6" \"where's sai\" -- The only object contained in 'where' matching \"sai\" (possible $ambiguous_match).";
7" \"where's second staff\" -- The second object contained in 'where' matching \"staff\".";
8" \"my third dagger\" -- The third object in your inventory matching \"dagger\".";
9"Ordinal matches are determined according to the match's position in 'object-list' or, if a possessive (such as \"where\" above) is given, then the ordinal is the nth match in that object's inventory.";
10"In the matching room (#3879@LambdaMOO), the 'object-list' consists of first the player's contents, then the room's, and finally all exits leading from the room.";
11{string, olist, ?evalvars = 1} = args;
12if (!string)
13return $nothing;
14elseif (evalvars && (string == "me"))
15return player;
16elseif (evalvars && (string == "here"))
17return player.location;
18elseif (player.programmer && valid(object = $string_utils:literal_object(string)))
19return object;
20endif
21object = $su:match_aliases_generics(string, olist);
22if (valid(object))
23return object;
24elseif (object == $ambiguous_match)
25return $ambiguous_match;
26elseif (parsed = this:parse_ordinal_reference(string))
27return this:match_nth(parsed[2], olist, parsed[1]);
28elseif (parsed = this:parse_possessive_reference(string))
29{whostr, objstr} = parsed;
30if (valid(whose = this:match(whostr, olist)))
31return this:match(objstr, whose.contents);
32else
33return whose;
34endif
35else
36return object;
37endif

match_objlist_prop

Spec this none thisFlags rxdOwner #361Definer #44

Referenced by

none

Source

1{string, olist, prop} = args;
2for x in (olist)
3if (string == x.(prop))
4return x;
5elseif ((length(string) < length(x.(prop))) && (x.(prop)[1..length(string)] == string))
6return x;
7endif
8endfor
9return #-1;