TinTin++ Mud Client Manual
Variable
space
Syntax: #variable {name} {string}
space
Variables differ from the %0-99 arguments in the fact that you can specify a full word as a variable, and they stay in memory for the full session unless they are changed. They can be saved in the coms file, and can be set to different values if you have two or more sessions running at the same time. Variables are global for each session and can be accessed by adding a $ before the variable name.
space
Example:
#alias {target} {#var target %0}
#alias {x}      {cast 'acid blast' $target}
space
The name of a variable must exist of only letters, numbers, underscores and the first character of a variable name must always be a letter. If you do not meet these requirements do not panic, simply encapsulate the variable in braces:
space
Example: #variable {cool website!} {http://tintin.sourceforge.net} chat I was on ${cool website!} yesterday!
space
Variables can be nested using brackets, causing the variable to behave like an associative array.
space
Example: #var hp[self] 34;#var hp[target] 46
space
You can see the value of the first nest of a variable using $variable[+1] and the last nest using $variable[-1]. Using $variable[-2] will report the second last value, and so on.
space
You can see the key of the first nest of a variable using *variable[+1], to see all keys use *variable[] or *variable[%*].
space
To see the nesting index of a variable use &variable. To see the total number of nests use &variable[].
space
Notice: The nesting index of a non-existent variable is 0, so you can check if a variable exists using #if {&{variable}}
space
Notice: You can remove variables with the #unvariable command.
space
See also: Format, Function, Local, Math, Replace and Script.
space