|
Working with script variables |
|
Written by eaxs
|
|
Wednesday, 26 August 2009 23:32 |
Variables are often referred to as CVars (or Console Variables). They are pieces of data temporarily stored in memory and are essential to any form of scripting or programming.
Types of variables
- Bool (Boolean) -- A simple true or false.
- Float (Floating Point) -- An Arbitrary real number.
- Int (Integer) -- A highest number.
- String -- A series of characters.
Creating variables In Savage 2 scripting, we use the CreateVar command to create a new variable.
Create a bool variable
Create a float variable Create an int variable Create a string variable CreateVar string test yes Modifying the value of a variable Once we have created our variables we can modify the value by using the Set command. Please note that you must not try to change the value to a different type! For example you cannot give an integer variable a string value.
CreateVar bool test true
Set test false Predefined game variables Savage 2 has many predefined variables to store all kinds of settings such as building definitions, unit definitions, abilities, spells and common game settings. All these variables can be modified through scripting by simply overwriting the default values. You can find the game variables in the game_settings.cfg in your savage2/game folder.
|