VARIABLES
(VR)
RECEIVER
Used for managing variables (setting, comparing and doing math with them).
Check the bottom of this section for notes on comparing game parameters and variables. Please also look at the Flags and Variables section. Some information is redundant but understanding Variable and Flag management is essential.
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; |
Management of variables All numeric variables are integer variables and have a range of -2147483647...+2147483647 a not yet used b not yet used c stores today value (game active day number) d adds or subtracts values from variables 'f' through 't' : Standard variables (former known as quick variables) v1 through v10000 : Standard variables w1 through w100 : Hero variables z1 to z1000 : String variables x1 through x16 : Function parameters y1 through y100: Function local variables z-1 through z-10: Function local string variables You can use conditional flags as usual. |
OPTIONS
Commands with variables
| C$1/$2/$3; |
!!VR$:C$1/$2/$3... up to 16 parameters Set/check v vars. $ - v variables 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 #] |
| 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 |
| S#; | Set var @ to # (now and below # may be another var by name) |
| 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. |
Comparison of variables
| &$; | And [1&1=1, 1&0=0, 0&1=0 0&0=0] |
| |$; | Or [1&1=1, 1&0=1, 0&1=1 0&0=0] Comments: !(!|?|#)XX&c1/c2/c3|c4/c5/c6:...; Full condition is: (c1 AND c2 AND c3) OR c4 OR c5 OR c6 Comments. - OR section may be alone or only after AND section - if there is only OR section, full condition will be true if at least one OR condition is TRUE - there may be up to 16 AND conditions and up to 16 OR conditions |
Arithmetic Operation with Variables
| +#; | Add # to the variable |
| -#; | Subtract # from the variable Example: !!VRi:-1; subtract 1 from i |
| *#; | Multiply the variable by # |
| :#; | Divide the variable by # (do not divide by zero - you will get an error message) |
| %#; | Set the variable to the reminder from division by # No brackets please :-) |
Commands with string variable
| !!VRz# | We have string variables.
z1...z500 Here are all changes for using string variables. |
| 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, NewLine, 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 |
| S^text^ | Set current string variable to ^text^ (text may be formatted) |
| S# | Copy string variable # to current string variable |
Show Variable inside string or Message
| %Vf...%Vt | Show *quick* variable |
| %V1...%V1000 | Show common variable |
| %W1...%W100 | Show hero's variable |
| %X1...%X16 | Show parameter |
| %F1...%F1000 | Show an ERM flag value |
| %Y1...%Y100 | Show local variable |
Concatenation of String
| +# | Concatenate string variable # with current string (add to the end) |
| +^text^ |
Concatenate string variable # with current string (add to the end, text may be formatted) |
How to check a variable?
Usage:
- to set value of the variables use "?VarName". May be used
everywhere that you can use a comparison operation (<,=,>).
- to use value of the variable use "VarName" instead of a number.
Example:
!!IF&v100=v1000/v100=5:...;
!!HE-1:P?v100/?v1000/0;
Example:
!?LE3/3/0;
!!HE3/3/0:P?i/?j/?k; // store current position (3,3,0) in i,j and k
!!HE3/3/0:P7/5/0; // jump to 7,5,0
!!HE7/5/0:Pi/j/k; // jump back to i,j,k (3,3,0)
Here is the example of VR usage:
!!VRi:S10+90:5-3;
!!IF:M^Variable i=%Vi.^;
In a result you will get the message: "Variable i=17."
To compare the game parameter to a particular value you can use the following way: ...[compare operator] value... The result of comparing is stored to Condition Flag 1. You can use its value for further ERM
Instructions and Example:
|
!!GE100:F5 |
Set first day to 5 for Time event (standard syntax) |
|
!!GE100:F=5 |
Check if first day is 5 and set Cond.Flag1 (CF1) |
|
!!GE100:F<>5 |
Check if first day is NOT 5 and set Cond.Flag1 (CF1) |
|
!!GE100:F><5 |
The same |
|
!!GE100:F>5 |
Check if first day is greater than 5 and set CF1 |
|
!!GE100:F>=5 |
Check if first day is greater or equal to 5 and set CF1 |
|
!!GE100:F=>5 |
The same |
|
!!GE100:F<5 |
Check if first day is below than 5 and set CF1 |
|
!!GE100:F<=5 |
Check if first day is below or equal to 5 and set CF1 |
|
!!GE100:F=<5 |
The same |
How to use a Hero's w variables:
also see Flags&Variables
section and IF:W section
To use the w variables, you first have to use an !!IF command to specify which hero they will apply to (use -1 for current hero).
Once you've
done this command, you don't have to use it again until you switch to another
hero (or if you don't know in advance which hero it will apply to). Use this
command before setting, testing, or checking a w variable.
So if you wanted to use w variables with hero #147 (Dracon), the command would
be:
!!IF:W147;
Then you could set the w1 variable in exactly the same way that you would set
any other variable (see example below).
You have
1 object and 1 event. If the hero has visited the object, the event will
recognize it.
Okay, let's say the object is a Magic Well located at x=10,y=15,level=0.
Let's say the event is located at x=27,y=18,level=0.
ZVSE
!?OB10/15/0;
!!IF:W-1;
!!VRw1:S1;
!?LE27/18/0;
!!IF:W-1;
!!IF&w1=0:M^Perhaps you should visit the Magic Well to the west for I
desire water!^;
!!IF&w1=1:M^You have brought me water from the Magic Well! I will reward
you!^;
How can I get the actual day?
It is easy.
!!VRv123:Sc;
Modifier 'c' work the same way as 'd' but add "the current day".
You can add current day to any other value.
!!HE-1:Fcd/c/1/2;
Add to attack of a hero current day, set defense to current day.
Tips on generating random numbers
Let's say you want to generate a number from 1-100,
but not 42, 81, or 99.
That's 3 missing numbers, so generate a random number from 1 to 97. Then if it's
42 or greater add 1. Then if it's 81 or greater add 1. Then if it's 99 or
greater add 1.
You now have a random number, with equal probability for each result, that's
1-100, but not 42, 81, or 99.
You can obviously exclude a range at a time and so on. It takes one line per
exclusion, which is what your recursive method takes. Only it's faster and not
recursive.
- So if you want a number from 1-100
excluding 10-19 and 73, you generate a number from 1-89, then if it's 10 or
greater add 10, then if it's 73 or greater add 1.
- Let's use the same method to generate a number from 1-10, but not 6. So
we generate a number from 1-9, and if it's 6 or greater, add 1.
Number from 1-9 -
1 2 3 4 5 6 7 8 9
If 6 or greater add 1 -
1 2 3 4 5 7 8 9 10
Each number has the same odds.