I think I assumed you had a little more knowledge of this than you actually do, apologies if I did (/you do and I'm now being patronising).
Let's start with the discretion between variables and functions.
Variables are numbers that you can manipulate, and they come in 3 tasty methods:
- Integers (declared with 'int'😉
- Booleans (declared with 'bool'😉
- Floats (declared with 'float'😉
Booleans can only have two values, '0' and '1'.
In script, they are given 'true' and 'false', and are great for switches and the like.
Integers and Floats are a little misleading.
ZScript makes no discretion between int and float, all integers and all floats are numbers with up to 4 decimal places (so there are no real integers).
You declare vairables like this:
bool fooieo;
bool foo = true;
int bar;
int barieo = 15;
I've never used floats personally.
And to use a variable you must first declare it, or the script will not compile properly.
The first line declares the boolean 'fooeio', and sets it to 'false'
The second line declares the boolean 'foo', and sets it to 'true'
The third line declares the integer 'bar', and sets it to '0'
The fourth line declares the integer 'barieo', and sets it to '15'.
You can then access your variables at other points during the script just by putting in their names.
Don't put the declaration word before them again, because you can't declare two variables with the same name in the same scope.
Functions are what you'll find in ZScript.txt, and are all (well, most of them are) accessed with pointers.
Let's take the function 'GetCurDmapScreen()'.
This function returns the value of Link's screen in the current DMap.
Referring to ZScript.txt, it is in the 'Game' section, so to access it, we use the 'Game->' pointer.
Like so:
Game->GetCurDmapScreen()
So, this function returns an integer, but at the moment we aren't doing anything with it, so let's combine it with an integer we declared earlier, and an if command:
int foo;
foo = Game->GetCurDmapScreen();if(foo == 10){//do something nice}
So we declared the integer foo, then we set it to the current Dmap Screen.
Notice that this line ends in a semi colon, as is the way with functions.
Then we checked whether foo was equal to 10, then if it was, we did something nice. (well, don't just put notes and then write out what you want the script to do, it won't work very well =P).
http://www.purezc.com/forums/index.php?showtopic=25946
This thread is great for understanding integers.
I haven't covered everything you asked, but it's quite important that you understand that much.
I'll go over the other bits, and post a bit of example script of how to do what you're asking after you get this much.
EDIT: Don't you just hate it when two people've posted by the time you've finished writing what you're saying =P