!!VR@:XXXX; |
All numeric variables are integer variables and have a range of -2147483647...+2147483647
| e1..e100 | Function floating point variables |
| e-1..e-100 | Trigger local floating point variables |
| 'f'..'t' | Standard variables ('quick variables') |
| v1..v1000 | Standard variables |
| w1..w100 | Hero variables |
| w101..w200 | Hero variables |
| x1..x16 | Function parameters |
| y1..y100 | Function local variables |
| y-1..y-100 | Trigger-based local integer variables |
| z1..z1000 | String variables |
| z-1..z-10 | Function local string variables |
|
OPTIONS
|
var C$1/$2/$3... up to 16 parameters |
Set/check v vars.
@ - v variable that is first in sequence
$1 - set/check a first (@) v variable
$2 - set/check a second (@+1) v variable
$3 - set/check a third (@+2) v variable
... and so on ...
Example:
!!VRv123:C23/v15/?i/y4;
Result: v123=23, v124=v15, i=v125, v126=y4
VR:C command can be used to define tables; it's a much cleaner way to do stuff like look up a spell number.
Example:
!!VRv600:C0/3/5/15/27/31/32/35/37/41/42/43/46/53/54; [table of 1st level spell numbers]
!!VRy1:S600 R14; [random # 600-614]
!!VRvx16:Svy1; [now vx16 is a random 1st level spell number] |
string H# |
Checks whether @ stores an empty string or not
# is a number of flag to store the result
flag#=1 if there is a text
flag#=0 if string is empty.
All signs like Space, New Line, Carriage Return, Tabulation are skipped and treated as NO characters.
Example:
!!VRz100:S^Hello!^;
!!VRz101:S^^;
!!VRz102:S^ ^;
!!VRz100:H300; flag300=1
!!VRz101:H301; flag301=0
!!VRz102:H302; flag302=0 |
string M1/z#1/#2/#3 |
Get a substring.
@ - a variable that receives the result; may be standard or local z variable.
z#1 - a variable that is a source; may be standard, local or extended z variable.
#2 - start position of z#1 string to copy (0 based).
#3 - length of substring to copy.
Example:
!!VRz1:S^NTV PLUS for Heroes!^;
!!VRz2:M1/z1/4/7; In result we have z2=PLUS fo |
string M2/z#1/#2 |
Get a specific token #2 from z#1 and set it to @.
@ - a variable that receives the result; may be standard or local z variable.
z#1 - a variable that is a source; may be standard, local or extended z variable.
#2 - a token number (starting from 0).
Comments: Delimiters are: space, comma, dot, tabulator, new line.
Example: For a string:
A string.of ,,tokens and some more tokens
We have the next tokens:
0 -> A 1 -> string 2 -> of 3 -> tokens
4 -> and 5 -> some 6 -> more 7 -> tokens
|
string M3/#1/#2
M3/#1 |
Integer to alpha conversion.
Convert a number to a string.
@ - a variable that receives the result; may be standard or local z variable.
#1 - any number (or any numeric variable) to be converted.
#2 - radix; a base of a value (default is 10)
Example:
!!VRz1:M3/123; -> z1=123
!!VRz1:M3/123/10; -> z1=123 (the same as above)
!!VRz1:M3/-123;-> z1=-123
!!VRz1:M3/127/16; -> z1=0x7F (hexadecimal) |
string M4/$ |
Get the length of a string.
$ - any numerical variable (to store the length)
Comment: Includes the full length, including leading and trailing spaces.
Example:
!!VRz10:S^ Abc def ^; Assign text to string z10
!!VRz10:M4/y5; Get length to y5. y5 returns 9 |
string M5/$ |
Get the first non-space character position.
$ - any numerical variable (to store the position)
Comment: If there are no leading spaces, the position is 0. If the string is empty, the position is -1.
Example:
!!VRz10:S^ Abc def ^; Assign text to string z10
!!VRz10:M5/y6; Get 1st non-space position to y6. y6 returns 2. |
string M6/$ |
Get the last non-space character position.
$ - any numerical variable (to store the position)
Comment: If there are no trailing spaces, the position is the length of the string -1. If the string is empty, the position is 0.
Example:
!!VRz10:S^ Abc def ^; Assign text to string z10
!!VRz10:M6/y7; Get last non-space position to y7. y7 returns 8. |
var R$ |
Generate a random value from 0 to $ (inclusive) and ADD this to the current value.
Example:
!!VRi:R25; will generate a random value from 0 to x (including) and ADD this to the current value |
var R#/$ |
Set random generator seed as one value on all PCs.
# - dummy parameter (is not used)
$ - random seed to set a random generator to a fixed sequence.
Comment: If you are not sure that the random generator is in identical stage at both PCs, you may just reset it to an identical seed and then generate a number. |
var S# string S^text^ |
Set var @ to # or set string @ to text (text may be formatted) |
var T$ |
Generate a random value from 0 to $ and add this to the current value of the variable Random value based on time value. In some cases these values may be more "random" than with the R command. Comments: Also, for those of you using VR:T to generate random numbers: if you generate more than one number at once, they'll all be the same. So use VR:R in those situations. T is a time based command. And if they both meet at one command line it is too little delay between them and as a result the values are the same. |
string U# U^text^ |
Search for a substring within a string
Searches for the substring z# or Text within the @ string and sets Flag 1 to TRUE if there is such a substring, otherwise to FALSE.
Z var in both sides may be of any type (standard, local, ERT based). This mean that this command may be easily ERTified.
Comments:
This uses a case insensitive algorithm, so "Sword" equals "sword" and "SwOrD". It skips leading and trailing spaces (and new line characters), so " Hi ", " hI" and " hi " all means just "HI" (all translated to upper case before searching).
It does not skip any space or new line characters that are located inside of the text. So "Hi, it's me" and "Hi, it's me" are different.
Both strings are processed before search procedure is executed. So the text like this "Hi,%Z5!" will become "Hi,Slava!" (if z5 is set to "Slava") before processing.
Example:
Here you will have both messages "Yes!" and "Yes again!":
ZVSE
!#VRz100:S^ Sword
^;
!#VRz200:S^ This_is the_sword text
^;
!#VRz200:Uz100;
!#IF&1:M^Yes!^;
!#VRz200:U^
sWorD ^;
!#IF&1:M^Yes again!^; |
var Vz$ |
Convert a string to an integer or floating point value
@ is any integer (f...t,v#,w#,x#,y#) or floating point (e) variable.
z$ - a var that is a source; may be standard, local or extended z
Comments:
You may use a ...e... syntax (engineering fl.p. format). If value may not be converted it is set to 0. Leading or trailing space characters are ignored.
Example:
!!VRz1:S^123^; !!VRv1:Vz1; - v1 = 123
!!VRz1:S^+123^; !!VRv1:Vz1; - v1 = 123
!!VRz1:S^-123^; !!VRv1:Vz1; - v1 = -123
!!VRz1:S^.325^; !!VRe1:Vz1; - e1 = 0.325
!!VRz1:S^-1.25e+1^; !!VRe1:Vz1; - e1 = -12.5 (-1.25 * 10^1) |
LOGICAL BIT OPERATIONS
|
&# |
Check or remove specific bit of a variable
& does a logical AND on the bits of a variable and can be used to check if a specific bit has been set. For example, to test if the variable v1 has the 5th bit (16) set, use: !!VRv1:&16;
v1 will be set to 16 if bit 5 is set and 0 if it isn't. This can be very useful when checking monster flags.
Example:
!!BRx16:F?i; read flags
!!VRi:&33554432; just look at waiting bit
!!IF&i>0:M^This stack is waiting.^;
You can also clear (remove) a specific bit without touching the other bits in a variable. To do so, use the negative minus one of the bit value you wish to remove. For example, to remove the 5th bit (16), use -17, e.g., !!VRv1:&-17;
To check or unset several bits at once sum their values. E.g. to remove 4th(8), 3rd(4) and 1st(1) bits use &-14 ( =-1*(8+3+1)-1 ). To check them use &13. |
|# |
Set a specific bit of a variable
| does a logical OR on the bits of a variable and can be used to set a specific bit without changing the other bits. For example, to set the 6th bit (32) for v1, use: !!VRv1:|32;
If v1 already had this bit set, nothing is changed. If it didn't, it now has this bit set. This can be very useful for adding new flags to a monster if you don't know which ones it already has, and in fact, this is really the only completely safe way to do so.
To set several bits at once sum their values. E.g. to set 5th(16) and 3rd(4) bits use |20 |
X$ |
Does a logical XOR on a bits of a variable
E.g. X-1 will invert bits of a variable.
To check for difference between two variables use syntax :VR@:X$ , where @ is variable which is one of variables to compare and also will keep the result of comparison. $ is second comparing variable.
Example:
Say v1=163 (10100011) and v2=106 (01101010). Then after
!!VRv1:Xv2; v2 is still 106.
| 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 | 1 | 0 |
XOR | - | - | - | - | - | - | - | - |
| 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 |
So v1=201 (11001001) |
ARITHMETIC OPERATIONS WITH VARIABLES
|
var +# string +^text^ |
Add # to the variable or add the text to the end of the source string |
var -# |
Subtract # from the variable |
var *# |
Multiply the variable by # |
var :# |
Divide the variable by # (do not divide by zero - you will get an error message) |
var %# |
Set the variable to the reminder from division by # No brackets please :-) |