User Tools

Site Tools


Sidebar

hpl2:tutorials:script:localandglobalvariables

Variables

A variable is letter or word used to represent a value that can be altered. The main types of variables are bool, string, int, and float. Bool is when the variable can be true or false. String is a letter, word, or phrase. Int is an integer (whole number). Float is a number with a decimal (can also be a whole number).

Examples:

int x = 1;
int k = 73;
float r = 5;
float pi = 3.1415;
bool tf = false;
bool w = true;
string h = “h”;
string aa = “lava”;

Local and Global Variables

Local and global variables are variables that have a certain scope compared to the script in which it is located in. There are certain levels of scope to a script, there is the function's scope, then there is the local scope, then there is the global scope.

Function's scope

A function's scope consists of everything within its braces ({ }). Normal variables as shown above will only work in a function unless carried over to another function.

hpl2/tutorials/script/localandglobalvariables.1310585517.txt.gz · Last modified: 2011/07/13 19:31 by kyle