Author Topic: Scope of Structs in Script Hierarchy  (Read 1917 times)

Scope of Structs in Script Hierarchy
« on: 09 Jul 2008, 19:17 »
I'm running into a problem with the way AGS deals with script/struct scope. Or maybe I still remain fundamentally confused on exactly how importing and exporting things works in AGS. Anyway, where I'm getting stuck at is when I'm trying to use an instantiated struct lower on the script list in a different struct (its definitions) that is higher on the list. Alright, we know that the order of the scripts on that list matters, that the lower scripts have access to those above it, but not the other way around. But I thought that's where importing/exporting stuff came into play. I've tried a bunch of different ways to try and get the scripts higher on the list to recognize instances of lower structs (token can't be identified) but to no avail. So, does anyone have any insight into this matter? Any workarounds? All I basically want to do is make an instance of a struct truly global so that any script--be it room or module--can have access to it (much like the global variables in the global variables node).

If it's not possible, I know I probably can always shove all the structs and their definitions into a single script file at the top of the list, but I really don't want to if I don't have to. The AGS manual led me to believe that I could achieve what I wanted by instantiating and exporting the struct variables in the global script file...

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Re: Scope of Structs in Script Hierarchy
« Reply #1 on: 09 Jul 2008, 20:12 »
import/export makes things available to lower-down scripts. If you don't import/export its only available to the same script. So your only solution for what you want is to put your thing in the topmost script.