Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: LostTrainDude on Thu 01/09/2011 14:18:39

Title: SOLVED: How to import an int variable in the header file of a new module?
Post by: LostTrainDude on Thu 01/09/2011 14:18:39
Probably it's simplier than I imagine.
Anyway, I'm still a coding newcomer :)

I've created a new script. I've written variables and functions in the .asc file and imported them in the .ash file.
I've no problems at all with functions but I get an error message when trying to compile rows of code such as these:


import int x;
import int y;


The error message I get says: "Script link failed: Runtime error: unresolved import 'x'"

If it matters, in the script file (.asc), these variables has a value of 0:


int x = 0;
int y = 0;


Is there something I should do, that I didn't?
Title: Re: How to import an int variable in the header file of a new module?
Post by: Gilbert on Thu 01/09/2011 14:34:47
Functions don't need to be exported, but variables have to be, before they can be imported to other scripts.

int x = 0;
int y = 0;
export x, y;

Title: Re: SOLVED: How to import an int variable in the header file of a new module?
Post by: LostTrainDude on Thu 01/09/2011 14:45:28
Thanks a million, now works perfectly :)
And I confirm that it was simplier than I thought.

Thanks again!