Declairing variables and calling a function

Started by Suto, Thu 04/03/2004 06:29:35

Previous topic - Next topic

Suto

Im having coding troubles...  obviously ;D
How do you go about declairing variables?
I've read the thing about data types but how are you guys declairing variables like...
#define DIR_DISTANCE 10000 and stuff
like is that one of those "text script event refrences" or whatever.
In VB you could just declair your own variables and reference them in a function,
this is pretty close, I mean how far off am I?  But what im really asking is can you make your own functions, or do you have to use the available event ones?


Gilbert

No, your example is not how one declares variables, it's how you define constants.

To declare variables, just do the simple C-style declarations like for example:

int blah;

If you put the declaration inside a function, it's local to that function only, and can't be used from other functions, so you can declare variables of teh same names within other functions without any dependencies.
If you put it on top of a (global or room) script, it's global to that script, ie. you can refer to it in the lines that follows in that particular script.
Note that variables declared in the global script is "global" for the global script only, they're NOT initially accessible by room scripts, if you want a variable declared in the global script to be accessible by a room script, you need to use methods like import and export, or better, use GlobalInts, etc. You can find all the infos form the manual.

SMF spam blocked by CleanTalk