Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: monkey0506 on Wed 15/02/2006 22:40:38

Title: Global functions...
Post by: monkey0506 on Wed 15/02/2006 22:40:38
I don't suppose it's possible to import a function into one header (a script header) and actually define it in a different script?  It's giving me errors when I try to do this.  Any help would be appreciated.
Title: Re: Global functions...
Post by: RickJ on Thu 16/02/2006 00:39:49
I'm not sure I correctly understand what you're asking but here is what I know about the subject:

Global functions must be defined in the Global Script file.  They can then be imported into all of the room script file by placing the appropiate import statement in the Script Header file.  Alternatively the import statement can be placed in each Room Script file where it is used.  AFIK you can't define a function in one Room Script file and then import it into another Room Script or Global Script file.

Title: Re: Global functions...
Post by: Gilbert on Thu 16/02/2006 01:46:37
For obvious reasons, the engine does not load all the rooms upon start (and the editor won't load another room CRM to look for functions when saving a room file or compiling the global script), and rooms data will be considered unloaded whenever the game changes room.
Title: Re: Global functions...
Post by: monkey0506 on Thu 16/02/2006 12:34:49
I was referring to script modules.  I wanted to put the import statement in one module but define the function elsewhere.
Title: Re: Global functions...
Post by: SSH on Thu 16/02/2006 12:46:39
Maybe if you explain what you are trying to achieve, we can make some suggestions?
Title: Re: Global functions...
Post by: strazer on Thu 16/02/2006 13:48:31
If at all, I think you can only import functions from modules placed before in the module manager. Same way you can't call functions from the global script in modules because modules are processed before the global script & header.
Title: Re: Global functions...
Post by: monkey0506 on Thu 16/02/2006 22:08:41
By "elsewhere" I meant the global script.  I wanted to import a function from the global script into a module header.  But with some thought, I've found a different (better) way of achieving the same thing.