unresolved import

Started by beomoud, Tue 10/02/2009 00:02:09

Previous topic - Next topic

beomoud

I can't seem to call my functions to my local scripts from my global script. I have already put a import keyword in the global script header but it doesn't recognize it. I chose to import in my local script instead but it gives me a message saying:

---------------------------
Adventure Game Studio
---------------------------
Script link failed: Runtime error: unresolved import 'Character::Scale'

---------------------------
OK  
---------------------------

the import is: import function Scale(this Character*, int factor);

What is that?

Pumaman

Where is the actual Scale function code? If it's in the room script, you can't call it from the global script.

Room scripts can call the global script, but the global script can't call into room scripts (because that room might not be loaded at the time).

beomoud

#2
It's in the global script imported into the script header and i was calling it from another script but that didn't work. i had to place it in another script and the import in the other script's header in order to have access to it... Is there a problem here?

The same thing happened when i tried to use a variable that i had declared in the global script and imported into the script header. When i finally decided to declare the variable in the global header when i called it from my room it returned a null value...

Generally variables i declare in the global script header, when i call them from a room their value returns back to their initial even though i have changed it in the global script

Khris

Declaring a variable in the header creates several, equally-named variables. Don't ever do that.

Code: ags
//globalscript.ash

import function Scale(this Character*, int factor);

import int g_var;

// globalscript.asc

function Scale(this Character*, int factor) {
  ..
}

int g_var;
export g_var;  // variables need to be exported


Unless you want to use an array, it's better to use the Global variables pane.

beomoud

#4
I did it this way but every variable i declare in the global script, import it into the global header and call from a room i get this message, just like before:

---------------------------
Adventure Game Studio
---------------------------
An internal error has occurred. Please note down the following information.
If the problem persists, post the details on the AGS Technical Forum.
(ACI version 3.12.1071)

Error: Unable to create local script: Runtime error: unresolved import 'foe'

---------------------------
OK   
---------------------------

global script:
int foe;

script header:
import in foe;

then the message...

I don't need to export them from the global script now do i?

Khris


beomoud

It turn's out that i do. I am so embarrassed about this, i have been using AGS for more than a year and a half but i didn't know that...sorry.. i thought that even if it isn't recommended to declare variables in your script header you could still do so.  

SMF spam blocked by CleanTalk