Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: arrtisste36 on Sat 11/12/2010 15:13:03

Title: help using the text parser
Post by: arrtisste36 on Sat 11/12/2010 15:13:03
I don't use the text parser globally in the game, but there are a few sections where I want the player to answer riddles using a text box.  Here is my code:

  gTextBox1.Visible = true;
  riddle = Answer.Text;
  Parser.ParseText(riddle);
  if (Parser.Said("chess [game]"){
    cDarkKnight0.Say("That's correct!");
  }else{
    cDarkKnight0.Say("That's incorrect.");
  } gTextBox1.Visible = false;

I keep getting an error that says "end of input reached in middle of expression."  Am I missing something stupid?
Title: Re: help using the text parser
Post by: Dualnames on Sat 11/12/2010 16:46:17

 gTextBox1.Visible = true;
 riddle = Answer.Text;
 Parser.ParseText(riddle);
 if (Parser.Said("chess [game]")) {
     cDarkKnight0.Say("That's correct!");
 }
  else{
     cDarkKnight0.Say("That's incorrect.");
 }
gTextBox1.Visible = false;


You just forgot a small  ) on   if (Parser.Said("chess [game]")) {  
I fixed the code above, so you can copy replace.
Title: Re: help using the text parser
Post by: Khris on Sat 11/12/2010 19:02:30
Two things: please always point out the line which the error refers to in case things aren't clear.
And you'll probably want to move the code that handles the input into the TextBox's OnActivate function.
In the code you posted you're turning on the GUI holding the textbox I guess, so subsequently riddle will be "" and nothing will happen.