2. Assembly of the scripting language

Calling a DestinyScript

The comment function of the RPG-Maker is used to call a DestinyScript. Because they are not only used for DestinyScripts (they are used for "common" comments, too) every DestinyScript begins with a dollar sign ($). This symbol has been chosen because it looks like a S and the word "script" starts with a s. It is important that the first char of the RPG-Maker comments needs to be the $ sign (this even means there may not be spaces or something else before the dollar sign) otherwise the RPG-Maker comment will not be interpreted as DestinyScript.
Information
If a RPG-Maker comment should be a "common" comment, but starts with a $ sign, it will be interpreted as DestinyScript and could show error messages. You can solve the problem if you put a space in the front of the $ sign. So the $ sign isn't the first symbol of the RPG-Maker comment anymore. In the RPG-Maker event command list the comment command looks like nearly the same.

The first example

At first we create a new (empty!) RPG-Maker project. Next we modify the RPG_RT with the RPG_RT.exe so that it loads the Destiny.dll. (Version: 1.0, Language: English, MessageLink: activiated, Number of dwords: 100, Number of doubles: 100, Number of strings: 100)
After generating the project we create a new event. First of all we have this code:
1
2
$
v[1] = 5
We paste this code now into a new RPG-Maker comment.
Calling the comment function
This graphic can vary from the used RPG-Maker version.
 
We insert a MessageBox among that comment, which displays the content of the first variable. (e. g. "Variable no. 1 has the value \v[1]")
If we call the event in game then we get the following result:
Message output of the game
We can see that variable no. 1 has the value 5. But why that? All variables of the RPG-Maker are by default initialized to 0. And given that it is a new (and complete empty) project there must something else been happen.
The answer is obvious: The DestinyScript assigned the value 5 to the variable no. 1!

Assembly of a DestinyScript

If we take a look at the example code again and think about its result then the meaning of the script will be clear.
1
2
$
v[1] = 5
In line no. 1 is the $ sign which tells the Destiny.dll that the RPG-Maker comment should be interpreted as DestinyScript.
In line no. 2 is the command which assigns the value 5 to variable no. 1. Such a command has always the same assembly. On the left side is the destination of the operation. In this case it is variable no. 1 (hence the v[1] - v stands for variable and [1] for the index!). In the center is the used operator. In this example this is the equal sign (=). On the right side is that what we want to assign to the destination (= source). In this case it is the number 5.
 
A DestinyScript may contain multiple commands. To separate them a semicolon (;) is used. A command needn't to be in a single line. But it is possible to write the entire DestinyScript into a single line (the leading $ sign needs not its own line!).
Information
The last command of a DestinyScript may end with a semicolon but it needn't to end with a semicolon.
As example a DestinyScript with more than one command could look like this:
1
2
3
$
v[1] = 5;
v[2] = 23
If we execute this DestinyScript the variable no. 1 will be 5 and variable no. 2 will be 23.
Information
Multiple commands can be written inside of a RPG-Maker comment. But the leading $ sign is only required once. Hence the $ sign may not be in front of each command!
It is expedient to make a important note here. If an error occurs during execution of a DestinyScript then the entire script will be aborted. This can be beneficial or even not. To avoid this you could write each command into a single RPG-Maker comment or change the error handling with the Errors object.