English
Chinese
  yTin Online Help  

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

format:            #math {variable} {expression}

Performs math functions and stored the result in a variable.   The math
follows a C-like precedence, as follows, with the top of the list having
the highest priority.

Operators                              Function
------------------------------------------------
!                                          logical not
------------------------------------------------
//                                       modulate (% in most languate, we use // to avoid confusion with variables)
/                                          integer divide
*                                          integer multiply
------------------------------------------------
+                                          integer addition
-                                          integer subtraction
------------------------------------------------
>                                          greater than (result is non-zero or zero)
>=                                       greater than or equal (result is non-zero or zero)
<                                          less than (result is non-zero or zero)
<=                                       less than or equal (result is non-zero or zero)
= or ==                                 equals (result is non-zero or zero)
!=                                       not equal (result is non-zero or zero)
------------------------------------------------
& or &&                                 logical and (result is non-zero or zero)
| or ||                                 logical or (result is non-zero or zero)
------------------------------------------------
Note: currently &, | are logic and/or, but please use && and ||, future version
might make &, | to bitwise and/or.

True is any non-zero number, and False is zero.   In the expression, you may
use T and F as true and false.   Parentheses () have highest precedence,
so inside the parentheses is always evaluated first.

examples:
#math {heals} {$mana/40}
Assuming there is a variable $mana, divide its value by 40 and store the
result in $heals.
#action {^You receive %0 experience} {updatexp %0}
#alias updatexp {#math {xpneed} {$xpneed-%%0}}
Let's say you have a variable which stores xp needed for your next
level.   The above will modify that variable after every kill, showing
the amount still needed.

See also: #variable, #if