Chcecking if inventory items are used in correct order

Started by vathox, Fri 08/04/2016 13:20:59

Previous topic - Next topic

vathox

Hi Guys!
I'm new to AGS and I'm totaly in love with it! But I have a small problem that i don't know how to solve. In my game player is supposed to place inventory items in correct order to make some fluid. If he puts them in wrong order he is going to explode. I have no idea how to chceck if he is putting them in correct order. Any suggestions?

Khris

Use a state variable.

Code: ags
// room script

int cauldronState = 0; // this is a room variable that retains its value

function oCauldron_Useinv() {

  InventoryItem *ai = player.ActiveInventory;
  bool dead = false;

  if (ai == iWater) {
    if (cauldronState == 0) cauldronState++;
    else dead = true;
  }
  else if (ai == iSpices) {
    if (cauldronState == 1) cauldronState++;
    else dead = true;
  }
  else if (ai == // etc...

  }
  else {
    // not an ingredient
    player.Say("Why would I put that into the cauldron?");
    return; // exit function
  }

  // something was put in the cauldron
  Display("You put the %s into the cauldon.", ai.Name);
  if (dead) {
    // explosion
  }
  else if (cauldronState == 5) {
    // done, magic happens
  }
}


SMF spam blocked by CleanTalk