Page 1 of 1

Variables? Whats that?

PostPosted: Fri Jun 16, 2006 8:35 pm
by duracel92
I have to make a variable, (first time to be honest) and I don't know where to start. I don't think the tutorials will work as well as a real person brain.

Well I guess first off I want to know what the buttons on the interface mean. The ones in the blue/teal. I know what integer means (number) but not what a string or real is.

And whats the difference between an actor variable and a global variable?

What is an array? Its a strange word by my books...

What would happen if I saved a variable to a save group? does this save the variable to load some other time?

Image


Sorry... But I have never used a variable before... They seem nasty and very hard to breach the learning curve to success (something intellectual and probably something stupid... :P )

Thanks! Its ok if you just don't bother to reply and just sit and laught at me... I'm not bothered...

PostPosted: Fri Jun 16, 2006 11:36 pm
by Game A Gogo
ok, firts of, interger and array...I DONT KNOW WHAT IT IS EITER.
and actor/global variable
Code: Select all
Global==the variable changes for all actor
Actor==The var only changes for the event actor, including clones

and if you save the var use
Code: Select all
SaveVar("Yourgruop","filename");//save the var
LoadVar("Yourgroup");//load the var
Its for being able to save the var and open it in an external Ged file on in the same.

PostPosted: Sat Jun 17, 2006 12:09 am
by plinydogg
An array is a container for holding a group of variables of a specified type.

int variableName; //this creates an integer variable called variableName
int variableArray[10]; //this creates an array of integers called variableArray

The number in brackets specifies how many integer variables are contained in the array (in this case 10).

Each integer contained in the array is accessed (for both reading and assigning values) using brackets and the number that refers to the value you want to access. In other words,

if you want, say, the sixth integer contained in variableArray to be set equal to six, you would do so with the following code:

variableArray[5] = 6;

CAREFUL: when you first create an array, the number in brackets is the number of integers you want the array to contain (in this case 10). However, when you want to access a particular integer in the array, YOU HAVE TO COUNT FROM 0 NOT 1. That's why to access the sixth integer in the array you have to refer to variableArray[5] instead of variableArray[6].

You can make other types of arrays too. You do this the same way you make an integer array except that instead of writing "int" before the array name, you write the type of variable you want the array to contain.

PostPosted: Sat Jun 17, 2006 12:14 am
by plinydogg
INTEGER: An integer is a whole number that can be either positive or negative.

These are integers: -431, 0, 4, 10000000
These are not integers: 4.560, -5.6

STRING: A string is a variable made up of letters, words, or blank space

These are strings: Hello, S, ""

REAL: I could be wrong about this (since I never use the "real" type) but I think real just means a non-integer number.

What type of variable you use depends on what you want to do with it. You can't use letters and words with an integer so if your variable is supposed to contain, say, your player's name, then you would have to use the string type.

Also, certain things in GE (and most programming languages) will only work with certain types of variables.

PostPosted: Sat Jun 17, 2006 12:20 am
by plinydogg
Only global variables can be saved.

A savegroup just provides a convenient way to save related variables in groups (I think that's all it does anyway). For example, let's say you have two players in a game. You might want to save all of player 1's variables in one save group and save all of player 2's variables in a second save group.

I'll try to answer more of your questions later, but I've gotta run for now...