IF
- Syntax: #IF expression true-command [false-command]
Allows conditional execution. If the expression is true, then the true-command is executed. If the expression is false, then the false-command (which is optional) is executed. Expressions can contain variables and operators.
IF examples
- #IF @autosplit {split @gold}
- If the @autosplit variable is non-zero, then the value of @gold is expanded, the string split is sent to the MUD followed by the value of @gold.
-
- #IF (@gold < 100000) {emote is poor} {emote is RICH!}
- If the value of the @gold variable is less than 100000, then the string emote is poor is sent to the MUD, otherwise the string emote is RICH! is sent to the MUD.
-
- #IF (@line =~ "You receive (%d) coins") {split %1}
- If the value of the variable @line matches the pattern You receive %d coins, then the number of coins matched is stored in the %1 parameter, and the string split is sent to the MUD, followed by the parameter. Note the nested quotation marks needed to properly parse this command.