yTin Online Help  

  Home (english) | Home (chinese) | Downloads | Sample scripts | Online help | Utilities | FAQs | Discussions/Messages | Mud&links | My Progs | Mirrors |

format:            #if {conditional} {command(s)}
                     #if {conditional} {command(s)} else {else-command}

The if command is one of the most powerful commands added since TINTINv3.
It works similar to an if statement in other languages, and is loosely based
on the way C handles its conditional statements.   When an if command
is encountered, the conditional statement is evaluated, and if TRUE
(any non-zero result) the command(s) are executed; if FALSE (0), the else-command
will be executed if there is "else {else-command}" followed.   The if statement is
only evaluated if it is read, so you must nest the if statement inside
another statement (most likely an action command).   The conditional is
evaluated exactly the same as in the math command, only instead of storing
the result, the result is used to determine whether to execute the
command(s).   '#help math' for more information.

New: #if now also compares string, so the #ifstrequal command is obsolte.
The string comparison is marked in [ ] pair.

#action {%0 gives you %1 gold coins} {#if {%%1>5000} {thank %%0}}
if someone gives you more than 5000 coins, thank them.

the %%1 and %%0 belong to the action, and not to the if, and that is why
the double % are needed.
RULE: each { } pair will need one more % to match.

#action {^#if {%%0<100} {flee}}
If your status prompt is of the form , this action
will get your hit points, compare them to 100, if less than 100, flee

#alias {walk} {#if {[%%0=1]}{#4 s;#2 e;enter};#if {[%%0=2]}{out;#2 w;#4 n};#if {[%%0=] || [%%0=help]}{#show 1: From camp to city, 2: From city to camp}}

See also: #math, #ifexist, #ifmatch