help using the text parser

Started by arrtisste36, Sat 11/12/2010 15:13:03

Previous topic - Next topic

arrtisste36

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?

Dualnames

#1
Code: ags

  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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Khris

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.

SMF spam blocked by CleanTalk