unresolved import error

Started by alisa_tana, Sat 09/02/2008 08:44:38

Previous topic - Next topic

alisa_tana

Again, I know I'm being stupid and missing something...

My script was getting much too big, so I've split it up into different modules (in the new 3.0 btw).  I've got a lot of variables I use throughout the different pieces, so I created one Script just for the variables, and put it at the top of the script list. 

In the ash I've got all of them as
Code: ags

import int ENEhealth;

and in the asc some of them have starting values:
Code: ags

int ENEhealth=120;


But I get an error when trying to run a test game:
QuoteScript link failed: Runtime error: unresolved import 'ENEhealth'

This is the 7th variable in the script, and one that's used in almost ever script.
I found a few other topics related to this error, but none of them seem to be the exact same problem...

If you need to see the whole thing, it's here


Gilbert

You have to export the variable in the global script before it can be imported.

So, something like:

int ENEhealth=120;
export ENEhealth;

alisa_tana

Ah okay... do I need to do the Export on every script that uses that variable, or just the first one?

Gilbert

You can only export a variable from the global script, so only one export is needed.
You can't export a variable from a certain room script and use it in other places.

alisa_tana

I'm trying to move things out of the rooms altogether, so no worries there...

I think I've managed to confuse myself now...

I have a script, titled variables, at the top of my scripts, that has the import in the ash so that all my other scripts can use them.... then I define them in the asc....  but I need to export them in the global script?  Can't be right, cause it tells me that I can't export an import.

Maybe I'm just not doing this the way I should.

I've got about 40 (give or take) variables that I want to use globally, throughout different parts of the script.  What's the best way of doing that?


Radiant

You need to export the variable in the one place where it is declared, which should be the first script in the order in which scripts are listed. The global script is usually the last script.

alisa_tana

AHH... okay.  I got it now.

Thank you very much for helping this poor fool.

SMF spam blocked by CleanTalk