Text Parser (SOLVED)

Started by Jon, Wed 22/11/2006 17:00:30

Previous topic - Next topic

Jon

Hi everyone, I have come across a part of my game which seems too complicated for me and my small mind.
I have a scene where the main character is locked up in a room, and the way the character gets out is by saying he is...
at this point i would like a text parser to come up with 'Who are you?', or something similar, as the title and if for example you said 'Tom' a message would come up and the guard would enter, but if you said 'Ted' a different message would come up which would eventually exit the conversation.
can anyone show me how this is done?
ta

an example of this would be in BJ 3 i think when the inspector guy is questioning you and you have to type in a code.
p.s. I couldn't find it in the manual or the links, but my computer won't go to most of them  :)

Ishmael

You can make a GUI with a textbox and a button in it, and have the button run a function which figures what was typed into the box and execute further stuff based on that.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Jon

D'oh just noticed the 'show the text parser' option, but when i make a dialog nothing comes up.
is there some sort of code I should know about? ???

Khris

Does the rest of the dialog work?
What exactly does "make the dialog" and "nothing comes up" mean?
Did you start the dialog? Can you see the dialog GUI at all?

Jon

dialog works fine if i add topics
but at the bottom there is a long text GUI
and if i type any word at all in, nothing happens.

Khris

Quote from: manualParser input

You'll notice in the dialog editor, a checkbox "Show text parser with this topic". If you check this, a text box is displayed below the predefined options, which allows the player to type in their own input.

If they type in something themselves, then the dialog_request global script function will be run, with its parameter being the dialog topic number that the player was in.

This is how you do The text parser in Dailogs-Conversations

Set up your Dilog  Script name, Option Names, Click show the text parser with this topic optons



Add words to the Text Parser

Hello  hi  and so on


Go the Global Script  under

#sectionstart dialog_request  // DO NOT EDIT OR REMOVE THIS LINE
function dialog_request(int parameter) {

// Add this  Example



if(cDrfreddy.Room == cEgo.Room)  // If your Drfreddy and your talking to EGO
{

   if (Parser.Said("hi")) { // what you type
     cDrfreddy.Say("hi");  // what you say
     
     cEgo.Say("Hello");  // NPC EGO Say
  }
 
 
  if (Parser.Said("Hello")) {
     cDrfreddy.Say("Hello");
     
     cEgo.Say("Hello");
  }
 
 
  if (Parser.Said("How are you")) {
     cDrfreddy.Say("How are you");
     
     cEgo.Say("Good");
    }


   if (Parser.Said("What are you selling")) {   // What you type
     cDrfreddy.Say("What are you selling");  // What you say
     
     cEgo.Say("Lab Stuff");  // NPC EGO says
       dEGO.Start(); // New Dailog Menu
       }

   
   if (Parser.Said("Selling any thing")) {
     cDrfreddy.Say("Selling any thing");
     
     cEgo.Say("Lab Stuff");
       dEGO.Start();
     }

 
  if (Parser.Said("Whats going on here")) {
     cDrfreddy.Say("Whats going on here");
     
     cEgo.Say("Maniac Mansion Tests");
  }
 
 
  if (Parser.Said("Is there any thing going on here")) {
     cDrfreddy.Say("Is there any thing going on here");
     
     cEgo.Say("Maniac Mansion Tests");
    }

}



Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

#7
Others


if (Parser.Said("Im going to kill you")) {
     cDrfreddy.Say("Im going to kill you");
     
     cEgo.Say("On No");
     StopDialog();
     character[EGO].Walk(500, 132);
   
   }



if (Parser.Said("Follow Me")) {
     cDrfreddy.Say("Follow Me");
     
     cEgo.Say("Ok");
     cEgo.FollowCharacter(player, 10,30);
     StopDialog();
     
   
   }



// Ramdom Reply

if (Parser.Said("hi")) {
        cSyd.Say("hi");

int ran=Random(7);
if (ran==0) cBernhard.Say("Hello");
else if (ran==1) cBernhard.Say("Hi");
else if (ran==2) cBernhard.Say("Hello There");
else if (ran==3) cBernhard.Say("What do you want");
else if (ran==4) cBernhard.Say("Go talk to DrFred");
else if (ran==5) cBernhard.Say("Are you talking to me");
else if (ran==6) cBernhard.Say("Hmm");
else if (ran==7) cBernhard.Say("Go away");
else cBernhard.Say("Hello");

   
  }
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Jon

Thanks for that Rubacant, that really helped!
I can now work the text parser, but after I type in the correct words, the other character replies as expected, and stops when I want, but I would like the character to move into the room (as he has just left).
Could someone please explain to me how this is done?

Jon

Sorry for double posting but I need to know the answer to the above question very quickly!
Could someone please help me?

Ashen

What exactly are you asking?
Where and when does the character leave the room, and why bother if you just want them to move back? Or have I misunderstood the problem?

I'll take a stab and suggest the Character.PreviousRoom property, e.g.:
Code: ags

Player.ChangeRoom(player.PreviousRoom);


But without knowing what you want, it's hard to be more precise.
I know what you're thinking ... Don't think that.

Jon

Sorry, your right I should have added more details.
My character is thrown in a cell by the guard, and he then exits.
If the player character walks onto a region near the door, a couple of dialogs take effect.
if the player character types the correct code into the text parser, than a function begins in which messages appear, and then the dialog ends.
This has been solved by some of the above posts.
What I want after this is for the Guard to come in the room then just look at the player character, then 'Guard' stays there while normal playing is resumed (Where the GUIs come back, I don't know what this is called  ???)
after a certain inventory item is used, the player exits the room (although this I think I can do by myself).

Many thanks

Ashen

#12
I still don't see where you need the help - you jump from something "which is solved above" to something "which I think I can do myself".
I'm sure it's all in the manual:
Moving characters between rooms: Character.ChangeRoom
Having Characters move around in the room: Character.Walk
Making Characters face a certain place; Character.FaceCharacter or Character.FaceLocation
Inventory Interations: See the BFAQ.
Placement of the code: Probably in the if(Parser.Said"...") condition, which I think you said you've got working.

Sorry if I'm still misunderstanding your question somewhere.
I know what you're thinking ... Don't think that.

Jon

#13
Don't be sorry AshenÃ,  ;D
It's my fault as I did not let other people understand the question I was asking, I was basically asking for the global script code for:

Move character
Face character
Use inventory on character - which then runs an animation

I shall take a look at your links now Ashen.

Edit: Thanks Ashen, your links helped me a lot!
There is still one problem I need solving though. I would like the region in which the dialog occurs, to change so that the player character can be moved to another room BUT only if the player character has used a certain inventory item e.g. inv item 7

Ashen

Quote from: Ashen on Tue 12/12/2006 21:48:57
Inventory Interations: See the BFAQ (also this one might help too).

Although only the second one is really of use here (I copied the links from another post, and didn't check which order they were in... the first one is kind of irrelevant to your question). You may also want a variable, if the item should only be usable after the dialog has been run.
I know what you're thinking ... Don't think that.

Jon

Thanks Ashen, I just realised that I could do the whole movement in one. So there would be no need to change the region.

SMF spam blocked by CleanTalk