VARIABLES
(VR)
RECEIVER
Used for managing variables (setting, comparing and doing math with them).
For a more detailed and explained version of VR receiver and variables, read the VR receiver easily explained (ERM for dummies, by Qurqirish Dragon)
!!VR@:XXXX; |
All numeric variables are integer variables and have a range of -2147483647...+2147483647
|
OPTIONS
var C$1/$2/$3...; |
!!VR$: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 ... Example: !!VRv123:C23/v15/?i/y4; Result: v123=23, v124=v15, i=v125, v126=y4 Example by Donald: Remember we have the VR:C command to define tables; it's a much cleaner way to do stuff like look up a spell number. So for 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 #] |
string H# |
Checks whether a z
variable stores an empty string or not # is a number of flag to store the result =1 if there is a text =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. !!VRz#:M1/z#1/#2/#3; Get a substring from z#1 and set it to z#. z# - 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 token. !!VRz#:M2/z#1/#2 Get a specific token #2 from z#1 and set it to z#. z# - 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 (0 based). 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. !!VRz#:M3/#1/#2; or !!VRz#:M3/#1; Convert a number to a string. z# - 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) Examples: !!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. |
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. |
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 for commands M4/$; M5/$; M6/$; : !!VRz10:S^ Abc def ^; [Assign text to string z10] !!VRz10:M4/y5; [Get length to y5] !!VRz10:M5/y6; [Get 1st non-space position to y6] !!VRz10:M6/y7; [Get last non-space position to y7] M4: y5 returns 12. M5: y6 returns 2. M6: y7 returns 8. |
|
var Rx; |
Generates a random value from 0 to
x (inclusive)
and ADDS 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#/$; ![]() |
Extended syntax for VR@:R command # - dummy parameter (is not used) $ - set random seed. |
var R$; ![]() |
New extended syntax for VR:R command $ - get/check/set random seed. In this receiver you MUST omit variable name! Thus, !!VRy1:R?y1 is WRONG and !!VR:R?y1 is GOOD. 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. Example: !!VR:R/?v1; will store current random seed in v1 !!VR:R/v1; will set random seed to v1 On start of a battle random seed is set to some value that don't change if you load savegame and attack the same monsters again. So, if you need some real randomness in battle, use: !!VRv1:S0 T2147483647 R/v1; randomize - use random seed based on current time |
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#; ![]() |
Search for a substring within a string: VRz#:U<substring> Format can be: !!VRz#1:Uz#2; or !!VRz#1:U^Text^; Searches for the substring z#2 or ^Text^ within the z#1 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!^; |
string V$; ![]() | Convert string to value. Convert a string to an integer or floating point value $ is any integer (f...t,v#,w#,x#,y#) or fl.(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. Examples: "123" -> 123 "+123" -> 123 (the same as above) "-123" -> -123 ".325" -> 0.325 "-1.25e+1" -> -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. For 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; |
|#; | 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. |
X$; | Does a logical XOR on a bits of a variable |
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 :-) |