A Variable can hold a value that may be changed at any time to something else. The use of variables is very valuable and one of its most common uses is keeping track and defining a target. If you set a variable to a certain value you can referr to the variable without having to worry about its value.
Let's look at an example. Say you want to assign the value "goblin" to a variable called "target".
Now you're free to create commands using this variable. Below you will find some examples:
Above you've seen how the variables found in the FMT can be used. There is another kind of variables though, but this kind is mainly used for scripts or storing temporarly values. While the variables in the FMT will save and load in your savefile, this other kind will not. From now on the variables in the FMT will be called persistent variables and this other kind will be called temporarly variables.
Temporarly variables is really VBScript variables and their main purpose is for use in scripts. This is an example of two temporarly variables called strOutput and lngLoop:
Dim lngLoop Function ROTFun(strIn) Dim strOutput For lngLoop = 1 to Len(strIn) strOutput = strOutput & Chr((Asc(Mid(strIn, lngLoop, 1)) + 13) Mod 255) Next ROTFun = strOutput End Function
After calling the function ROTFun("testing") two variables will have been used. strOut is internal for the function and will be erased as soon as the function exited. The variable lngLoop though has been defined outside the function and resides in the internal Scripting object. This variable will not be erased/reset til the scriting object is reset, hence its value will be whatever it was after the function exited.
Check this table for a comparison between persistent and temporarly variables:
Description | persistent | temporarly |
Session dependent | yes | yes |
Saves with savefile | yes | no |
Datatypes | Strings | Variants(all types) |