Trouble using text parser in dialogue

Started by Barbarossa, Sat 10/04/2004 16:14:57

Previous topic - Next topic

Barbarossa

I'm trying to achieve the effect of having a dialogue between a player and a chatacter, where progress is dependent on the player telling the charatcer the correct password. According to the manual, the game will use the player's typed input to run the function dialog_request in the global script with the parameter being the number of the topic the player is in. So far so good.
The manual also says that, before running this, the game will call ParseText with the input so you can use Said() calls to respond.
This is my entry in the global script function dialog_request:

function dialog_request (int param) {
 if (param == 1) {
   if (character[EGO].inv[3] == 0) {
     RunDialog(11);
     }
   else {
     RunDialog(10);
     }
   }
 else if (param == 9) {
   if (SaidUnknownWord ("44XYZ")) {
     RunDialog(12);
     }
   }
 }

"44XYZ" is the password they need to type and 9 is the number of the topic they type it in.
However, on testing, the game will proceed to Dialog 12 without checking whether the contents of the Unknown Word buffer was the correct password. Does anyone know how to get this to work? I've tried removing the quotes from the 44XYZ but then it won't run at all.

Thanks

Barbarossa

It's OK, I've worked it out! I just needed to put the password into the parser's list. I am not smart!   ::)

stuh505

Hello, I am new to AGS but your problem is a simple programming error.

First of all, I'd like to recommend

  • indent for flow of control

  • use descriptive variable names

    these two things will increase your efficiency at debugging

    anyway, you are using the unknown word function incorrectly.

    Quote
    function dialog_request (int param) {
       string buffer,
                        password = "44XYZ";

       if (param == 1) {
          if (character[EGO].inv[3] == 0) {
             RunDialog(11);
          }
          else {
             RunDialog(10);
          }
       }
       else if (param == 9) {
          if (SaidUnknownWord (buffer)==password) {
             RunDialog(12);
          }
       }
    }

    I have modified your code.  In theory this should work, but there are a couple points where it is possible for AGS syntax to differ; I am not sure if you are allowed to use the == operand to compare strings, and I am not sure if you are allowed to declare strings in the way I have done.  However, this is the correct way to write it.  You might just have to use a string compare function is all.

SMF spam blocked by CleanTalk