What am I doing wrong? (variables and dialogue)

Started by Nickydude, Sun 04/01/2009 23:18:51

Previous topic - Next topic

Nickydude

In the GlobalScrips.asc I placed the following variable in game_start (): int metbillgates; and in a dialogue I have:

Code: ags
  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?  :-\
Best Regards,
Nickydude
www.madladdesigns.co.uk

AGS Beginner's Guide - All you'll ever need!

Ghost

#1
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 ;)

Nickydude

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.
Best Regards,
Nickydude
www.madladdesigns.co.uk

AGS Beginner's Guide - All you'll ever need!

Matti

Wow. That smiley's beer gets refilled just when it's half-way through. Very practical..   :D

Trent R

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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Khris

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.

Nickydude

Best Regards,
Nickydude
www.madladdesigns.co.uk

AGS Beginner's Guide - All you'll ever need!

Dualnames

If a variable is defined inside a function it will only be useful in that function.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk