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
CreateVar bool test true

Create a float variable
CreateVar float test 1.0

Create an int variable
CreateVar int test 1

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.
Comments
Add New
Write comment
Name:
Email:
 
Title:
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."