matching utilities #44
Aliases: matching utilities
14 verbs · 17 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
match | this none this | rxd | #44 | 32 |
match_nth | this none this | rxd | #44 | 66 |
match_verb | this none this | rxd | #44 | 11 |
match_list | this none this | rxd | #44 | 18 |
parse_ordinal_reference parse_ordref | this none this | rxd | #44 | 27 |
parse_possessive_reference | this none this | rxd | #44 | 19 |
object_match_failed | this none this | rx | #44 | 34 |
init_for_core | this none this | rxd | #44 | 4 |
match_ambiguous | this none this | rxd | #44 | 36 |
match_many | this none this | rxd | #44 | 80 |
match_bodyref | this none this | rxd | #44 | 22 |
parse_ordinal_reference_spunky_backup | this none this | rxd | #44 | 16 |
match_generics | this none this | rxd | #44 | 37 |
match_objlist_prop | this none this | rxd | #44 | 9 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
ordn | #44 | rc | #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 | #44 | rc | #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 | #44 | rc | #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 | #44 | r | #29 | #-1 |
ordinal_regexp_old | #44 | rc | #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 | #44 | rc | #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 | #72 | rc | #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 | #1 | rc | #29 | {"matching utilities"} |
description | #1 | rc | #29 | <clear> |
object_size | #1 | r | #29 | {22977, 1298433815} |
hidden_verbs | #1 | rc | #29 | <clear> |
phelp_msg | #1 | rc | #29 | <clear> |
weight | #1 | rc | #29 | <clear> |
owner_verbs | #1 | rc | #29 | <clear> |
plural_name | #1 | rc | #29 | <clear> |
client_image | #1 | rc | #29 | <clear> |
listening | #1 | rc | #29 | <clear> |
Ancestry
Ancestors (nearest first): #72 Generic Utilities Package → #1 root
Children: none
Call graph
Source
match
Referenced by
- #1:match line 1:
$match_utils:match - #1:named line 6:
$match_utils:match - #2:@tree line 7:
$match_utils:match - #2:@move line 10:
$match_utils:match - #3:-* line 4:
$match_utils:match - #3:-* line 7:
$match_utils:match - #3:match_someone line 3:
$match_utils:match - #5:give line 6:
$match_utils:match - #5:throw line 1:
$mu:match - #6:last_huh line 12:
$match_utils:match - #6:last_huh line 15:
$match_utils:match - #6:my_match_object line 2:
$match_utils:match - #6:ex*amine line 9:
$match_utils:match - #6:page line 18:
$mu:match - #6:repair line 2:
$match_utils:match - #6:teach line 24:
$match_utils:match - #6:@nude line 3:
$mu:match - #6:wear line 12:
$match_utils:match - #6:track line 1:
$mu:match - #6:remove line 18:
$match_utils:match - #6:pee line 1:
$mu:match - #6:pee line 3:
$mu:match - #6:learn line 1:
$match_utils:match - #6:learn line 7:
$match_utils:match - #6:pose line 1:
$mu:match - #6:taunt line 3:
$mu:match - #6:taunt line 9:
$mu:match - #6:job*s line 80:
$mu:match - #6:@attach line 11:
$mu:match - #6:compliment line 2:
$mu:match - #6:hints line 19:
$mu:match - #8:p*ut line 2:
$match_utils:match - #8:match_object line 2:
$match_utils:match - #33:ready line 37:
$mu:match - #33:pick line 6:
$mu:match - #44:match_ambiguous line 29:
this:match - #44:match_ambiguous line 30:
this:match - #44:match_many line 75:
this:match - #44:match_bodyref line 13:
$mu:match - #44:match_bodyref line 18:
$mu:match - #44:match_generics line 30:
this:match - #44:match_generics line 31:
this:match - #50:sizeup line 1:
$match_utils:match - #50:murder line 6:
$match_utils:match - #50:murder line 14:
$match_utils:match - #50:murder line 24:
$match_utils:match - #50:res*urrect line 2:
$mu:match - #50:_kick line 11:
$match_utils:match - #50:heal line 5:
$mu:match - #50:@task*s line 30:
$mu:match - #50:@task*s line 58:
$mu:match - #50:seccheck line 6:
$match_utils:match - #54:match_backup line 1:
$match_utils:match - #54:clean line 3:
$match_utils:match - #54:match_contents line 2:
$mu:match - #54:count line 8:
$mu:match - #54:old_count line 6:
$match_utils:match - #55:drag line 1:
$mu:match - #55:__push line 1:
$mu:match - #55:push line 2:
$mu:match - #89:@morph line 1:
$mu:match - #95:@setup line 31:
$match_utils:match - #97:match line 2:
$match_utils:match - #100:sc*ore line 16:
$mu:match - #100:help line 23:
$mu:match - #100:help line 25:
$mu:match - #103:match_wristpad line 2:
$match_utils:match - #104:get_as_it_once_was line 4:
$match_utils:match - #104:cut line 6:
$match_utils:match - #107:do_command line 24:
$match_utils:match - #107:do_command line 25:
$match_utils:match - #107:at*tack line 11:
$match_utils:match - #107:l*ook line 40:
$match_utils:match - #107:l*ook line 42:
$match_utils:match - #107:l*ook line 59:
$match_utils:match - #107:diag*nose line 6:
$match_utils:match - #107:cure line 6:
$match_utils:match - #107:count line 1:
$mu:match - #107:count line 8:
$mu:match - #107:get_all line 18:
$match_utils:match - #107:get_all line 23:
$match_utils:match - #107:get_all line 31:
$match_utils:match - #107:drop line 11:
$match_utils:match - #107:stow line 7:
$match_utils:match - #107:dress line 7:
$match_utils:match - #107:get line 15:
$match_utils:match - #107:bolt line 2:
$match_utils:match - #107:junk line 2:
$mu:match - #107:spare line 16:
$mu:match - #111:@setup line 32:
$match_utils:match - #118:_old_render line 25:
$match_utils:match - #118:_render_BACKUP_OLD line 22:
$match_utils:match - #119:uninstall line 1:
$mu:match - #121:compile line 12:
$match_utils:match - #127:install line 1:
$match_utils:match - #128:light line 5:
$match_utils:match - #129:put line 15:
$match_utils:match - #149:wave line 2:
$mu:match - #167:biz_contracts line 8:
$mu:match - #167:biz_contracts line 19:
$mu:match - #167:biz_hire line 3:
$match_utils:match - #167:biz_fire line 3:
$match_utils:match - #167:biz_promote line 3:
$match_utils:match - #167:biz_demote line 3:
$match_utils:match - #167:biz_access line 8:
$match_utils:match - #167:biz_salary line 6:
$match_utils:match - #167:biz_successor line 6:
$match_utils:match - #167:biz_voteout line 48:
$match_utils:match - #230:match line 3:
$match_utils:match - #284:@grant line 6:
$mu:match - #284:@revoke line 6:
$mu:match - #317:@allitems line 8:
$match_utils:match - #317:@sizeup line 2:
$match_utils:match - #317:@sizeup line 3:
$match_utils:match - #317:@aspy line 1:
$mu:match - #317:@rspy line 3:
$mu:match - #317:@scope line 8:
$mu:match - #317:@itemreport line 3:
$mu:match - #334:focus line 15:
$match_utils:match - #334:bury line 7:
$match_utils:match - #334:bury line 23:
$match_utils:match - #334:instantiate_old line 35:
$match_utils:match - #334:instantiate_old line 36:
$match_utils:match - #335:match_target line 1:
$mu:match - #338:fill line 1:
$mu:match - #338:toast line 5:
$mu:match
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
Referenced by
- #44:match line 22:
this:match_nth - #44:match_ambiguous line 26:
this:match_nth - #44:match_generics line 27:
this:match_nth
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
Referenced by
- #33:last_huh line 7:
$match_utils:match_verb - #33:last_huh line 9:
$match_utils:match_verb - #89:last_huh line 6:
$match_utils:match_verb - #89:last_huh line 8:
$match_utils:match_verb
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
Referenced by
- #44:object_match_failed line 21:
$match_utils:match_list
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
Referenced by
- #44:match line 21:
this:parse_ordinal_reference - #44:match_ambiguous line 25:
this:parse_ordinal_reference - #44:match_generics line 26:
this:parse_ordinal_reference
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
Referenced by
- #44:match_ambiguous line 27:
this:parse_possessive_reference - #44:match_generics line 28:
this:parse_possessive_reference - #310:parse_pose_args line 29:
$match_utils:parse_possessive_reference
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
Referenced by
- #6:@attach line 14:
$mu:object_match_failed - #33:pick line 8:
$mu:object_match_failed - #50:@task*s line 32:
$mu:object_match_failed - #50:@task*s line 60:
$mu:object_match_failed - #317:@itemreport line 5:
$mu:object_match_failed
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
Referenced by
none
Source
1if (caller_perms().wizard) 2pass(); 3this.matching_room = $nothing; 4endif
match_ambiguous
Referenced by
- #338:fill line 21:
$match_utils:match_ambiguous
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
Referenced by
- #6:wear line 3:
$mu:match_many - #107:drop line 21:
$match_utils:match_many - #107:drop line 34:
$match_utils:match_many - #107:get line 26:
$match_utils:match_many - #107:get line 52:
$match_utils:match_many
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
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
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
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
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;