lib-match

A series of matching routines. You should be using one of these instead of any number of other 'match' macros. :)

.noisy_matchitemname -- itemdbrefTakes a string with a possible item name in it. It returns the dbref of the object is if is found. If it is not found, it tells the user that it doesn't see that here and returns #-1. If it finds several matches it tells the user that it doesn't know which item was meant, and returns #-2.
.noisy_pmatchplayername -- playerdbref This routine takes a string with a possible playername and returns the dbref of that player, if it can find it. If it cannot find the player, then it tells the user that it doesn't know who that is, and it returns #-1.
.controlsplayerdbref objectdbref -- controlled? This routine takes a player dbref and an object dbref and returns an integer value of 1 if the player controls that object. Otherwise it returns a 0. If your program doesn't need to be portable to a non-glow server, I would opt to use the muf primitive "controls" instead.
.match_controlleditemname -- itemdbref This routine basically does a .noisy_match, and checks that what is returned is controlled by the user. If it is not, then it tells the user Permission Denied, and returns #-1. Otherwise it returns the dbref of the item matched.
.multi_rmatchobjref smatchstr -- dn .. d1 n] This function takes a dbref for the thing/player/room that it is to match in, and a smatch style comparison string and returns the dbrefs of all the contained objects within who's names matched the string. There is an integer on top giving how many dbrefs were returned. If no items were matched, it only returns a 0.
.table_matchxnone xambig sn xn .. s1 x1 n comp func -- smat xmat This function tests comp against s1 through sn, returning the matching compatator-data pair if it finds one match. It returns a null string and xnone if no matches are found. It returns a null string and xambig if more than one match was found.
This function takes, in order:
  • a data value of any type to return if no matches are made. {xnone}
  • a data value of any type to return if the match is amiguous. {xambig}
  • a range of comparator {sn - s1}, and data {xn - x1} pairs of any type.
  • an integer count of how many comparator-data pairs are on the stack to be compared against. {n}
  • a value of the same type as the comparators, that will be checked against each comparator. {comp}
  • the address of the function that is used to compare comp against s1 through sn. This function should take the two datums for comparison and return a 1 for a match or a 0 for a non-match. {func}
.std_table_match This function runs .table_match with a standard comparator fuction that expects the comparators to be strings. The match comparator routine matches if comp matches the beginning of the comparator exactly. ie: a comp of "#h" would match a comparator {s1 - sn} of "#help".

feaelin@kemenel.org
lib-match / Revised 2004 March 31 22:06 (Wednesday)
© 2004 Iain E. Davis

Green Web Hosting! This site hosted by DreamHost. Standards Now! Valid XHTML 1.1! Valid CSS! We rated with ICRA!