Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gepard on Fri 09/02/2007 16:35:53

Title: int not working
Post by: Gepard on Fri 09/02/2007 16:35:53
Well. I was trying to make this work, but its hopeless  :-[. When I click on the hotspot it always give back just the first sentence: "Its a cactus." It doesnt go any further in the script. I started this as an empty game, is that the reason why?

// room script file
    int cactus;

#sectionstart hotspot1_a  // DO NOT EDIT OR REMOVE THIS LINE
function hotspot1_a() {
  // script for Hotspot 1 (cactus): Look at hotspot

if (cactus == 0) {
    character[RILE].Think("Its a cactus.");
  }
  if (cactus == 1) {
    character[RILE].Think("SOMETHING.");
    character[RILE].Think("SOMETHING.");
  }
  if (cactus == 2) {
    character[RILE].Think("SOMETHING.");
    character[RILE].Think("SOMETHING!");
  }
}
Title: Re: int not working
Post by: scotch on Fri 09/02/2007 16:51:26
That's because cactus is never changed. When you want it to move to the next value of catus you should add one to it. Your code would look like this:

if (cactus == 0) {
Ã,  Ã,  character[RILE].Think("Its a cactus.");
Ã,  Ã,  cactus++;
Ã,  }
else if (cactus == 1) {
Ã,  Ã,  character[RILE].Think("SOMETHING.");
Ã,  Ã,  character[RILE].Think("SOMETHING.");
Ã,  Ã,  cactus++;
Ã,  }
else if (cactus == 2) {
Ã,  Ã,  character[RILE].Think("SOMETHING.");
Ã,  Ã,  character[RILE].Think("SOMETHING!");
Ã,  Ã,  cactus++;
Ã,  }
}

Or you could just put cactus++ at the end, after the whole if/else section, so it's incremented once every time the hotspot is looked at, whatever happens.
Title: Re: int not working
Post by: Gepard on Fri 09/02/2007 17:01:25
thanks a lot!
Title: Re: int not working
Post by: Khris on Fri 09/02/2007 17:41:29
If there are going to be a lot of situations like this in your game, you might wanna take a look at the MultiResponse module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=27947.0).