Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ashen on Tue 27/09/2005 13:56:47

Title: Do I need to import GUI pointers?
Post by: Ashen on Tue 27/09/2005 13:56:47
So, I know how to make a GUI pointer (GUI *myGui;), and I know that if I put that in the script header, the myGui pointer will be available in every room/script. BUT if I set myGui (myGui = gInventory;) in the global script, it's only usable in the global script - unless I also put a myGui = gXx in (for example) a room script, it crashes as a null pointer.

It's not, obviously, a major problem - I can just watch what/where I call - I was just wondering if there was a way to keep the settings across scripts.
Title: Re: Do I need to import GUI pointers?
Post by: strazer on Tue 27/09/2005 15:22:00
You can export/import pointers just like variables:


// main global script

GUI *myGui; // define pointer for use in global script
export myGui; // export pointer for use in room scripts


then


// main script header

import GUI *myGui; // import pointer for use in all rooms


or


// room script

import GUI *myGui; // import pointer for use in this room


I hope I have understood you correctly.

Edit:

Quote from: Ashen on Tue 27/09/2005 13:56:47
So, I know how to make a GUI pointer (GUI *myGui;), and I know that if I put that in the script header, the myGui pointer will be available in every room/script.

If you define variables/pointers in the script header, a seperate variable will be created for the global script and every room script. So if you change the pointer in the global script, it doesn't affect the pointer in the room script.
Title: Re: Do I need to import GUI pointers?
Post by: Ashen on Tue 27/09/2005 15:30:49
QuoteI hope I have understood you correctly.

Yes, you have. I thought I'd tried every combination of import/exporting them - including that one - but I guess not, as it now works. Thank you, although I now feel like a total n00b.