Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Sun 29/01/2006 17:30:29

Title: Counter Problem (Solved)
Post by: on Sun 29/01/2006 17:30:29
I am unsure of what I am doing wrong here.

int Key;
   if (Key == 1) {
           Display ("It's already unlocked.");
   }
   if (Key == 0) {
           Display ("Hooray!  It unlocked.");
        Key = 1;
   }

When the action is done, it displays the "Hooray..."  but when I repeat the action, it "Hooray"s again.  Any suggestions?


(Figuring out how to do all this can be a real pain  :P)

Title: Re: Counter Problem
Post by: DoorKnobHandle on Sun 29/01/2006 17:32:17
It's because you define "int key" right above where you use it. It will create a new "key" variable everytime you execute that piece of code (and it will always initialize the variable with a value of "0").

Move the "int key" to the global script file.

EDIT: What is strazer talking about..? :=
Title: Re: Counter Problem
Post by: strazer on Sun 29/01/2006 17:39:11
Quote from: dkh on Sun 29/01/2006 17:32:17or the script header.

Don't. (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=24444.msg304162#msg304162) :)
Title: Re: Counter Problem
Post by: on Mon 30/01/2006 00:00:05
Thanks guys, it's working fine now.  Woohoo, I'm one more step closer to making my game!  ;D