Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ryan Timothy B on Fri 28/05/2010 17:27:47

Title: Variable in header question
Post by: Ryan Timothy B on Fri 28/05/2010 17:27:47
I created my own module script and in the header I declared a variable.  I can access this variable via any script, but I've noticed today that I can't actually alter the variable.  Is there some kind of import/export routine required here?
Title: Re: Variable in header question
Post by: RickJ on Fri 28/05/2010 18:19:42
The contents of the header are included (i.e. inserted into) every script.   So what you have done is declare separate variables in each script, each having the same variable name but not the same contents.  I think what you want to do instead is to put the variable declaration and export statement in the module script and then put a corresponding import statement in the header.


// *** Module Script ***
int MyVariable;
export MyVariable;

// *** Module Header ***
import int MyVariable;
Title: Re: Variable in header question
Post by: Ryan Timothy B on Fri 28/05/2010 18:32:08
Ah, right on.  I didn't know it actually declared them in each script, no wonder why I was getting crazy results.

Is the export actually required?  Would import not do the work of export?

Edit: Never mind.  I discovered that it results in a bad import. :P  Thanks.