Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Toimia on Mon 03/08/2015 00:13:36

Title: Issues with ROL command
Post by: Toimia on Mon 03/08/2015 00:13:36
Hi All,

I've been working on a text parser project and have run into an issue with the ROL command. In principal the text parser is working as intended, but not the way I want it.

Here is the current code:

GLOBAL Script
Code (ags) Select
if (Parser.SaidUnknownWord())
  {
    Display("Not recognized.", Parser.SaidUnknownWord());
  }
else
{
   CallRoomScript(1);
}


ROOM Script
Code (ags) Select

function on_call (int reason) {
if (Parser.Said("press rol")) {
    gParser.Visible = false;
    cEgo.ChangeRoom(3);
  }
else
{
    NoMatch(); //if none of above matched player's input, NoMatch() function is called.
}
  }


Currently it will only process "press" or "press rol" ONLY if the ROL part is a word in the text parser dictionary(press button etc).

If I swap the CallRoomScript and Display commands around it will work fine but ONLY if "press" has a word after it (E.G. "press rubber dingy rapids"). I have tried using an || operator for "press" and "press rol" but no luck. Same problem if I try to do it in a separate IF command.

I want the script set up so I can type "press (anything)" and it will run through the same command regardless of it being in the dictionary or not.

I am sure it's something simple I'm missing, but after spending several hours trying to debug this..I am struggling now.

Any thoughts appreciated! :)
Title: Re: Issues with ROL command
Post by: Khris on Mon 03/08/2015 01:37:16
Parser.SaidUnknownWord() will only return null if all words were recognized. That way you're counteracting the "rol".
You need to always call CallRoomScript(1), then check against available actions, then use Parser.SaidUnknownWord() (best in a global function).

Also note that Display first expects a string with insertion markers, then the variables to be inserted. To display the word you have to use:
  Display("Not recognized: %s", Parser.SaidUnknownWord());