體例說明
{} | 大括號 | 必要敘述 |
[] | 中括號 | 選擇性敘述 |
"" | 雙引號 | 文字(不分大小寫) |
NL | new line | 表示需另起新行 |
\ | 反斜線 | 為排版方便所作的斷行。實際上要和下一行合併。 |
程式語法
">" {trigger_type} " " {argument_list} "~"
NL
{program_command_1} NL
{program_command_2} NL
{program_command_3} NL
. . .
{program_command_N} NL
"~" NL
trigger_type 的種類和用法另有專章介紹。program_command 可以是 DR 內的任何指令或判斷式,但不能超出怪物的能力範圍。詳細的介紹請參考 MOBcommands 的教學。你可以為同一隻怪物設計很多段不同的程式,但不論你設計了幾段程式,最後請以 | 為 MOBprogram 結尾。
範例
>greet_prog 100~
以 100% 的機率啟動 greet_prog
say Hello, world!
說說話
dance
跳跳舞
~
結束本段
控制流
"if" " " {if_check_1} "(" {argument}
")" [ {operator} \
{value} ] NL
[ "or" " " {if_check_2} "(" {argument}
")" [ {operator} \
{value} ] NL ]
. . .
[ "or" " " {if_check_N} "(" {argument}
")" [ {operator} \
{value} ] NL ]
[ {program_command_1} NL ]
[ {program_command_2} NL ]
. . .
[ "break" NL ]
. . .
[ {program_command_N} NL ]
[ "else" NL ]
[ {program_command_1} NL ]
[ {program_command_2} NL ]
. . .
[ "break" NL ]
. . .
[ {program_command_N} NL ]
"endif" NL
因為是基本的語法,if, else, or, and, break, endif 的用法就不多作說明了。
原始文件中的範例
>act_prog p pokes you in the~
if isnpc($n)
chuckle
poke $n
else
if level($n) <= 5
or isgood($n)
tell $n I would rather you didnt poke me.
else
if level($n) > 15
scream
say Ya know $n. I hate being
poked!!!
kill $n
break
endif
slap $n
shout MOMMY!!! $N is poking me.
endif
endif
~
判斷式中所用的變數,另有專文介紹。
數值運算元
== | 相等 |
!= | 不相等 |
> | 大於 |
< | 小於 |
>= | 大於等於 |
<= | 小於等於 |
& | and 運算元 |
| | or 運算元 |
字串運算元
== | 相等(完全比對) |
!= | 不相等(完全比對) |
/ | 部分相等 |
!/ | 部分不相等 |
假設怪物的全名是 cityguard puppet,則:
if name($n) == cityguard puppet
true
if name($n) == puppet
false
if name($n) != cityguard puppet
false
if name($n) != puppet
true
if name($n) / guard
true
if name($n) !/ guard
false
補充:字串的比對有分大小寫。