当前位置:   article > 正文

zmud之技巧备忘_zmud函数

zmud函数

http://www.zuggsoft.com/library/

zmud编程技术可以搜索"Zmud机器人制作--基础知识,技巧以及实例讲解"这篇文章,系统全面介绍了zmud编程的技术和技巧。<br />这里仅会提到常见的使用的技巧。<br />zmud编程最重要的是参考#help文档的commands/functions.

 

#ALIAS AddRange {#VAR N 0;#LOOP %1,%2 {#MATH N @N+%I};@N}

AddRange 5 8

You get a result of

 

26 (which is 5+6+7+8).

自定义函数(较复杂函数,具有LOOP功能)

#FUNC AddRange {%exec(#VAR N 0;#LOOP %1,%2 {#MATH N @N+%I};@N)}

 will do the trick. @addrange(5,8) returns a result of 26. Keep in mind that any text normally sent to the MUD is captured as the result of the %exec function. If multiple lines are send to the MUD, they are returned from %exec separated by the vertical bar (|) character.

 

Definition command

 

Alternative command

 

Resulting value stored in @test

 

Mode

 

#VAR test "@A/@B"

 

#FUNC test {@A/@B}

 

@A/@B

 

Verbatim

 

#VAR test <@A/@B>

 

#VAR test {@A/@B}

 

100/2

 

Expansion

 

#VAR test [@A/@B]

 

#MATH test {@A/@B}

 

50

 

Evaluation

 

用户自定义函数用@开头;系统自带函数用%开头。

函数中不能引用alias和command,只能嵌套函数。

函数参数以逗号分隔,用圆括号包围。如:@addrange(5,8)

 

<> 会展开里面的内容

[] 会计算里面的内容

{} 用来包含拥有alias和function的一系列表达式

"" 里面的内容不会被展开

 

zmud支持的正则表达式类型(Trigger的Pattern即是正则表达式)

  • . match any single character
  • * match zero or more of the previous pattern
  • + match one or more of the previous pattern
  • ? match zero or one of the previous pattern
  • (exp) group the regular expression "exp" into a single pattern
  • exp1 | exp2 match expression exp1 OR expression exp2. Any number of expressions can be listed, separated by |
  • [abc] match a range of letters. In this case, the letters a, b, or c are matched. You can specify a range of characters using the - operator. For example [a-z] matches any lowercase character. Putting ^ before the range defines a range of characters that are excluded. For example [^a-z] matches anything *except* a lowercase character.
  • ^ matches the beginning of line
  • $ matches the end of the line
  • / escapes the next character, matching that character verbatim. For example /* matches an asterisk. // matches a slash itself. Note that to prevent zMUD variable parsing the @ character must still be escaped with the normal zMUD escape character (default of ~) rather than the / character.
  • /s a space character (ascii 32)
  • /p the | pipe character
  • /w a word delimiter (matches /s!"&()*+,-./:;<=>?@[/]^`{|}~)
  • /h a hex character (0-9A-F)
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/718519
推荐阅读
相关标签
  

闽ICP备14008679号