They are compiled in the order:
AGS 3 requires you to declare things before you use them.
(Edit: In some quick testing, the crossed-out part doesn't seem to be correct, and it appears possible to import both functions and variables to script above where they are defined. The issue is within scripts, where you have to define things above where you use them.)which means that other scripts (other than the room scripts and dialog scripts) cannot use things that are declared in GlobalScript, because GlobalScript is always at the bottom of the script list. If you put an import statement in the header of the script above it will compile, but I am almost certain it will crash when it runs.
(In the new compiler in AGS 4, you can use forward declaration if you want to use something before the script that defines it, so this limitation no longer applies.)
See further discussion (including about how headers work) here: https://www.adventuregamestudio.co.uk/forums/advanced-technical-forum/ags-scripting-language-architecture/
- Scripts from the Script node of the project tree, in the order listed
- Dialog scripts
- Room scripts
AGS 3 requires you to declare things before you use them.
(Edit: In some quick testing, the crossed-out part doesn't seem to be correct, and it appears possible to import both functions and variables to script above where they are defined. The issue is within scripts, where you have to define things above where you use them.)
(In the new compiler in AGS 4, you can use forward declaration if you want to use something before the script that defines it, so this limitation no longer applies.)
See further discussion (including about how headers work) here: https://www.adventuregamestudio.co.uk/forums/advanced-technical-forum/ags-scripting-language-architecture/