int not working

Started by Gepard, Fri 09/02/2007 16:35:53

Previous topic - Next topic

Gepard

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!");
  }
}
Drink up me 'arties! Yo ho!

scotch

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.

Gepard

Drink up me 'arties! Yo ho!

Khris

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.

SMF spam blocked by CleanTalk