In the GlobalScrips.asc I placed the following variable in game_start (): int metbillgates; and in a dialogue I have:
if (metbillgates == 0)
{
GuyBrush: Hi
BillGates: Hello.
metbillgates = 1;
}
else
{
GuyBrush: Hi, it's me again
BillGates: Hello again.
}
Basically I want to say something different if I've talked to the guy before. But I keep getting "Dialog 0(4): Error (line 4): undefined symbol 'metbillgates'".
What's the obvious (to you guys) thing I'm missing here? :-\
The "obvious" thing is that your dialog cannot acess the int because it is "valid" only in the global script.
Since you're using the lastest AGS, you can simply create it as a "global int" and have acess to it from all other scripts, including dialogs (before that, we had to do a lot of fiddly stuff that was, well, fiddly).
Hit the Global Variables pane, create the variable there, and you should be fine ;)
I thought putting a variable in the GlobalScript would make it global.
QuoteHit the Global Variables pane, create the variable there, and you should be fine.
That worked perfectly, thanks again for your help Ghost. (http://www.comicguide.net/images/smilies/smilie_prost.gif)
Wow. That smiley's beer gets refilled just when it's half-way through. Very practical.. :D
Well, to have variables in global script be available globally, you need to put an export statement somewhere after it is declared (some like it on the next line, some like them all at the end).
Also, you said you put it in game_start(), in which case it's be out of scope and give you the same (or similar) error if you tried to use it anywhere else other than inside the game_start() function.
~Trent
Exactly, game_start is used to set/change existing global variables or call functions that need to run before anything else; declaring global variables is supposed to be done outside any function.
Thanks guys.
If a variable is defined inside a function it will only be useful in that function.