Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Sam. on Fri 17/12/2004 14:47:21

Title: Variables [SOLVED]
Post by: Sam. on Fri 17/12/2004 14:47:21
right, i want my player to have a limited freedom of choice . They have to complete everything in a room in order to progress, i want them to be able to choose which order to pick stuff up berofre an event happens. I thought, ill use a variable and then add to this integer everytime they do something, so when the variable reaches a certain value the event occurs. simple enough. i look up variables in the manual and learn to declare an integer i :

int progress;

so i declare my variable in the game start code.

I then need to add to this every time they do something so i ask on IRC, i get told to:

progress = prgress + 1;

no probs. But i then run and get told that prgress is unrecognised and so my game won't work. what am i doing wrong?

i
Title: Re: VAriables
Post by: Rui 'Trovatore' Pires on Fri 17/12/2004 14:49:14
Maybe because you mispelled it?

progress= progress + 1;

At any rate, it might be better to

progress++;

or

progress+=1;
Title: Re: VAriables
Post by: Sam. on Fri 17/12/2004 14:58:59
just tried that and I got "undefined Token"
Title: Re: VAriables
Post by: Rui 'Trovatore' Pires on Fri 17/12/2004 15:02:04
Oh, you declared int progress; in game start?

Ok, it's like this - if you only need the variable in THAT room, declare in in your ROOM script, BEFORE any code, kay? Inside NO function.

If you need it in more rooms, you declare it at the BEGINNING of the global script, not in game start. You declare it BEFORE any functions. Then at the end of the script you add "export progress;". And THEN you add "import int progress;" to your script header.

Again, if you only need this in one room, stick to the first method.
Title: Re: VAriables
Post by: Sam. on Fri 17/12/2004 15:08:45
cheers, solved now.
Title: Re: SOLVED- Variables
Post by: TerranRich on Sat 18/12/2004 01:20:03
Zooty, next time, check the BFAQ at least: http://bfaq.terran-x.com/#coding01

Thanks.