3. Data types

What are data types?

As a user of the RPG-Maker 2000 you already know 2 data types. At first variables and as second switches. But you can't compare a variable and a switch directly, because they save complete different values. A RPG-Maker 2000 variable can save values in the range from -999999 to +999999 (in the Destiny.dll you have a greater range - see table). But you can only use integer values (e. g. floating point numbers like 1.5 won't work!). A switch however can save only one of two values: on or off (constants: True and False). These two data types are available in different scopes (one for variables and one for switches). The Destiny.dll extends the RPG-Maker game by 3 additional scopes. At first a scope of the data type dword is added. This data type is complete identical with the data type of the variable. At second a scope of the data type double is added. This data type can save floating point numbers with a very huge range. At third a scope with the data type string is added. This data type saves text instead of numbers (e. g. names, words or complete sentences).

List of data types

The DestinyPatch knows 7 different data types.
Data typeSizeRangeUsage
Variable4 bytes-2147483648 ... +2147483647This data type is equivalent to the data type "dword"
Switch1 byte0 ... +1This data type can save only boolean values (yes or no). Usually the boolean constants True (= 1) and False (= 0) are used for this data type.
Dword4 bytes-2147483648 ... +2147483647This is the most common data type. It saves only integer values.
Word2 bytes-32768 ... +32767This data type is similar to dword, but this one has a smaller range. This data type is used only by a few methods, but its usable for data transmission. You can save traffic with it, because it needs only two bytes. This data type saves only integer values, too.
Byte1 byte0 ... +255This data type is similar to dword, but this one has a constitutive smaller range. This data type saves only very small numbers and needs hence only one byte in memory. This data type is used for pixels in a picture. This data type saves only integer values, too.
Double8 bytes-1.7E+308 ... -5.0E-324 ... +5.0E-324 ... +1.7E+308This data type can save very huge numbers, but in favor it requires much more space in memory. The accurancy is 15 integer/decimal places. This is the only data type that can save floating point numbers.
String4 + n bytesca. 0 ... +2147483647 ZeichenThis data type saves text (e. g. names, words or complete sentences).

Scopes

To save the result of an operation it is necessary to have some scopes in memory where the result can be stored. Scopes for the data types variable and switch are allocated by the RPG_RT.exe. The other scopes (for the data types dword, double and string) are allocated by the Destiny.dll. To access the scopes you can use their abbreviations.
AbbreviationData typeData sourceIdentifier
v[ ]VariableRPG_RT.exeV stands for variable.
s[ ]SwitchRPG_RT.exeS stands for switch.
d[ ]DwordDestiny.dllD stands for dword.
f[ ]DoubleDestiny.dllF stands for floating point number.
a[ ]StringDestiny.dllA stands for ANSI string.

We have already seen how to access a variable via the v abbreviation. You simply write down the abbreviation with some brackets behind it (the brackets must be written directly after the abbreviation!). You write down the index of the element you want to access inside the brackets (e. g. v[1] for the first variable, v[2] for the second variable, ...). The same principle works with other scopes, too.
1
2
3
$
d[5] = 100;
v[3] = d[5]
If we paste this example into a RPG-Maker comment and let subsequent display the value of the variable no. 3 in a MessageBox then we can see that the variable has the value 100. In this example we assigned first the value 100 to the dword no. 5. Subsequently we assigned the value of the dword no. 5 to the variable no. 3. On this way we assigned a value from a different scope to the variable no. 3.

Indirectly addressing

So far we accessed the elements of a scope only directly (e. g. v[1] for the first variable). An other way to access an element of a scope is the indirectly addressing. To do this we simply write an element of a scope instead of an immediate (fixed) number into the brackets.
1
2
3
$
v[4] = 5;
v[v[4]] = 17

If we execute this script and take a subsequently a look at variable no. 5 then we can see that its value is 17. In this example we accessed variable no. 5 indirectly. First we assigned in line 2 the value 5 (the index of the variable we want to access) to the variable no. 4. Subsequently we wrote in line 3 that we want to use the value of variable no. 4 as index instead of an immediate number.
Information
All scopes can be addressed indirectly. The scopes used for indirectly addressing can be addressed indirectly, too (e. g. v[v[v[1]]]). The maximum depth of indirectly addressing depends on the capacity of the computer where the game is running. Usually you needn't a deeper addressing depth than 1.

Conversion of data types

If the data types differ (e. g. if you want to assign a dword to a double) then the data types will be converted automatically. This happens inside of formulas or parameters, too. Only the mixed calculation of strings and numbers or switches and numbers raise an error. To do a calculation like this you must explictly convert the values using the Convert object.