Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Global Lint on Tue 03/03/2009 17:24:14

Title: Item Problem using Text Parser
Post by: Global Lint on Tue 03/03/2009 17:24:14
Here's what happens: The "Drink wine" code runs, but the 'get staff' code won't-- the game ignores the "get staff" command by the player.
When I put the "Get staff" code before the "Drink wine" code, only the "get staff" code runs, and the game completely ignores player input command "drink wine."  So whichever one comes first is the one that works.
This is using Magintz's text parser template.

int staff = 0;

//"DRINK WINE" CODE
else if (Parser.Said("drink wine")) {
  if (staff==1) { Display("No more for me, thanks!");
    txtParser.SetText("");}
  else if (staff==0){
    cEgo.Walk(214, 149, eBlock);
    Display("Bravely, you take hold of the wine glass. You clink your glasses together and drink every last drop. The alcohol has a slightly dizzying effect...");
    Display("Moments pass...");
    Display("With a jolt, the guard realizes that he has taken the poisoned wine! He reaches out as if to choke you, but before he can reach you, he falls to the floor, immobilized!");
      Display("With the guard unable to move, you freely take the staff. You can feel a strange strength emanating from it!");
      staff+=1;
      character[EGO].AddInventory(istaff);
      object[2].Visible = false;
txtParser.SetText("");}
//END OF "DRINK WINE" CODE


//"GET STAFF" CODE
   else if (Parser.Said("take staff")) {
      if (staff==1) { Display("You already have it");
      txtParser.SetText("");}
      else if (staff==0 && Region.GetAtRoomXY(player.x, player.y) == region[0]){
    Display("You need to get closer");
      txtParser.SetText("");}
else if (staff==0 && Region.GetAtRoomXY(player.x,player.y) == region[2]){
Display("'Ah, ah, ah! First we drink, then we'll talk about the staff!'");
      txtParser.SetText("");}
//END OF "GET STAFF" CODE
Title: Re: Item Problem using Text Parser
Post by: thezombiecow on Tue 03/03/2009 17:31:07
I can't remember how the parser works, off hand, but don't you need an 'if' statement, not an if else?


//"DRINK WINE"
  if (Parser.Said("drink wine"))
{
  if (staff==1)
  { Display("No more for me, thanks!");
    txtParser.SetText("");
  }
  else if (staff==0)
  {
    cEgo.Walk(214, 149, eBlock);
    Display("Bravely, you take hold of the wine glass. You clink your glasses together and drink every last drop. The alcohol has a slightly dizzying effect...");
      staff+=1;
      character[EGO].AddInventory(istaff);
      object[2].Visible = false;
txtParser.SetText("");
  }
}




//"GET STAFF" CODE
if (Parser.Said("take staff"))
{
      if (staff==1)
      {
      Display("You already have it");
      txtParser.SetText("");
      }
      else if (staff==0 && Region.GetAtRoomXY(player.x, player.y) == region[0])
      {
      Display("You need to get closer");
      txtParser.SetText("");
      }
      else if (staff==0 && Region.GetAtRoomXY(player.x,player.y) == region[2])
      {
      Display("'Ah, ah, ah! First we drink, then we'll talk about the staff!'");
      txtParser.SetText("");
      }
}


Could be wrong, I haven't got AGS in front of me.  :)

Title: Re: Item Problem using Text Parser
Post by: Global Lint on Tue 03/03/2009 17:48:39
It works perfectly!  Thank you very, very much  :)
Title: Re: Item Problem using Text Parser
Post by: thezombiecow on Wed 04/03/2009 09:38:01
QuoteThank you very, very much

No worries. Glad it's working. :)