Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: vathox on Fri 08/04/2016 13:20:59

Title: Chcecking if inventory items are used in correct order
Post by: vathox on Fri 08/04/2016 13:20:59
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?
Title: Re: Chcecking if inventory items are used in correct order
Post by: Khris on Fri 08/04/2016 15:55:38
Use a state variable.

// 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
  }
}
Title: Re: Chcecking if inventory items are used in correct order
Post by: vathox on Fri 08/04/2016 18:26:05
Thanks! Works great!