TinTin++ Mud Client Manual
 ``` MATH Command: #math {variable} {expression} Performs math operations and stores 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 Priority Function ------------------------------------------------ ! 0 logical not ~ 0 bitwise not * 1 integer multiply ** 1 integer power / 1 integer divide // 1 integer sqrt // 2 or cbrt // 3 % 1 integer modulo d 1 integer random dice roll + 2 integer addition - 2 integer subtraction << 3 bitwise shift >> 3 bitwise shift .. 3 bitwise ellipsis > 4 logical greater than >= 4 logical greater than or equal < 4 logical less than <= 4 logical less than or equal == 5 logical equal (can use regex) === 5 logical equal (never regex) != 5 logical not equal (can use regex) !== 5 logical not equal (never regex) & 6 bitwise and ^ 7 bitwise xor | 8 bitwise or && 9 logical and ^^ 10 logical xor || 11 logical or True is any non-zero number, and False is zero. Parentheses () have highest precedence, so inside the () is always evaluated first. Strings must be enclosed in { } and use regex with == and !=, in the case of <= and >= the alphabetic order is compared. The #if and #switch commands use #math. Several commands accepting integer input allow math operations as well. Floating point precision is added by using the decimal . operator. Time in seconds is calculated using [day]:[hour]::. Example: #math {heals} {\$mana / 40} Assuming there is a variable \$mana, divides its value by 40 and stores the result in \$heals. Example: #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. Example: #action {%0 tells %1} {#if {{%0} == {Bubba} && \$afk} {reply I'm away, my friend.}} When you are away from keyboard, it will only reply to your friend. Related: cat, format, function, local, mathematics, replace, script and variable. ```