You are here: TWiki MARE > Sandbox Web > TestTopic0 r3 - 21 Nov 2007 - 23:16 - SluggyQBFreak


Start of topic | Skip to actions
  • Set TOPLINK = Top

Inzone()

inzone(<zone object>)

Returns a space-separated list of database reference numbers for each room that is linked to zone object. You must have ownership permissions on the zone object.

Top

Itemloc()

itemloc(<spell number>)

Returns the dbref location of forged item number spell number. Note that the $ is not used to reference the item.

Top

Nearest()

nearest(<list>,<target2>)
nearest(<list>,<target2>,<mode>)

This function returns the nearest number in a set of numbers--i.e. the element in <list> that is nearest to <target>.

<mode> can be one of L or G. If <mode> is l, the nearest number that <target> is less-than is returned, if <mode> is g, the nearest number that <target> is greater-than is returned. If <target> is not specified, the nearest match is chosen. If there are two matches equal distance from <target> the lesser number takes precedence. The closest match that can be made to a number is the number itself.

Examples:

Function Returns
[nearest(1 2 3 9,5)] 3
[nearest(1 2 3 9,5,L)] 9
[nearest(1 2 3 9,8,G)] 3
[nearest(1 2 3 4,4)] 4

See also: lnum()?, randword()?

Top

Path()

path(<object>,<destination>,<limit>)

This function returns a list of exit database reference numbers in a path between two points. The location of <object> is used as the starting point, and <destination> is the destination room. <limit> specifies the maximum number of rooms away to search from the location of <object>. The maximum value of <limit> is 100.

Top

Regmatch()

regmatch(<string>, <pattern>)
regmatch(<string>, <pattern>, <register>)

This function performs regular expression matching with <pattern> on <string>, returning 1 if there is a match or 0 if no match exists. The <pattern> may contain wildcards * and ?, but it must not begin with any boolean characters. The <pattern> is not case-sensitive.

This function has the side-effect of modifying the environment variables %0 through %9 with the text substituted by each wildcard in <pattern>. That is, the text matching the first * or ? becomes %0, the second becomes %1, and so on up through %9. Wildcards beyond %9 are not recorded but still determine whether a successful match takes place.

An optional <register> number from 0 to 9 can be specified. This determines the first environment variable to which the parser will begin recording matches.

If only the side-effect of the function is wanted, you can use [mid(x,0,0)] or [left(x,0)] to nullify the result.

Examples:

Command Displays
say Match=[regmatch(@set me=Dark,@set =)], env0=%0, env1=%1 You say, "Match=1, env0=me, env1=Dark"
say Match=[regmatch(Does not match,*k*)], env0=%0, env1=%1 You say, "Match=0, env0=, env1="
say [left(regmatch(abc def,* *,2),0)]env0=%0, env1=%1, env2=%2, env3=%3 You say, "env0=, env1=, env2=abc, env3=def"

Errors:

  • #-1 Invalid global register. - The <register> was not in the range 0 to 9.

See also: match()?, setq()?, setr()?

Top

S_as()

s_as(<expression>,<cause>,<player>)

Performs pronoun substitution and function evaluation on the given expression, using the priviledges and point of view of <player> and imitating the cause of the function from <cause>. Like s()?, this enables you to assign values to %# and %! as <cause> and <player>, respectively. You must be able to control both <cause> and <player> to perform an accurate substitution.

Examples:

Function Returns
[s_as({%N(%#) -> %U(%!)},me,here)] Gandalf(#14) -> Gandalf's Patch(#2)

See also: Pronouns?, s()?

Top

Setdiff()

setdiff(<list1>,<list2>)
setdiff(<list1>,<list2>,<input delim>,<output delim>)

This function returns the difference of two sets of words--i.e. the elements in <list1> that are not in <list2>. If <list1> contains duplicate words, then each occurrance of a matching word is removed from <list1>, and all other words remain unchanged. Words are matched case-insensitive.

Examples:

Function Returns
[setdiff(1 2 3,2 4 6)] 1 3
[setdiff(#3 #17 #19 #25 #180,#17)] #3 #19 #25 #180
[setdiff(Three and seven and ten,and)] Three seven ten

See also: setinter(), setunion()

Top

Setinter()

setinter(<list1>,<list2>)
setinter(<list1>,<list2>,<input delim>,<output delim>)

This function returns the intersection of two sets of words--i.e. the elements that are both in <list1> and <list2>. The resulting set will not contain any duplicate words. Words are matched case-insensitive.

Examples:

Function Returns
[setinter(1 2 3,2 4 6)] 2
[setinter(a b c d,A C E)] a c
[setinter(1 2 6 6 8,6 6 10)] 6

See also: setdiff(), setunion()

Top

Setunion()

setunion(<list1>,<list2>)
setunion(<list1>,<list2>,<input delim>,<output delim>)

This function returns the union of two sets of words--i.e. the elements in either <list1> and <list2> minus any duplicate elements. This function can be used with an empty set {} for <list2> to remove all duplicate words in a list. Words are matched case-insensitive.

Examples:

Function Returns
[setunion(1 2 3,2 4 6)] 1 2 3 4 6
[setunion(a b c d,A C E)] a b c d E
[setunion(12 4 7 4 9,{})] 12 4 7 9

See also: setdiff(), setinter()

Top

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r3 < r2 < r1 | More topic actions
[cached Nov 21 2008 at 07:06:20 - refresh]
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki MARE? Send feedback