Text Parser: One word.

Started by Dualnames, Sat 23/01/2010 16:08:13

Previous topic - Next topic

Dualnames

Perhaps this doesn't fit exactly in the technical, but rather in the beginners so I apologize if you think it should go there


Problem:

I'm using the code below to have player type a word, just to get an extra point.
Before player has the chance to type, the Narrator says:

"You feel like..eh..what's the word?"


Notes:
1. Blip is just the equivalent of cNarrator.Say("
2. The gui is called gWord, so when it closes, apparently game carries on.
3.txtwordy is the script name of the text box.


Caveats I've noticed so far:

1. If player says: "I'm no idiot" the game will understand idiot and parse response idiot.
2. I don't want to restrain player into one word response. It's sort of like giving the answer away.


Code: ags


function txtxwordy_OnActivate(GUIControl *control){

if (String.IsNullOrEmpty(txtxwordy.Text)==true) {//So if player accidentally presses enter it doesn't get considered as an input.
return;
}

if (txtxwordy.Text.Contains(GetTranslation("idiot"))!=-1) {//If player says idiot.
    blip("&321 Thank you.");
    blip("&322 An idiot is exactly what you feel like.");
    gWord.Visible=false;
    GiveScore(1);
    return;
}

else {//If a sentence doesn't contain idiot you get this response
        blip("&323 No, actually,'idiot' was the word I was looking for."); 
        blip("&324 In a reckless moment you go completely mad and decide that you ought to take Arthur with you.");
        blip("&325 You try to tell Arthur about the importance of getting a drink, but he's rambling on about a man called Prosser.");
        gWord.Visible=false;
        return;
}
}


So?
Any ideas on how to go through this differently and fix or restrain the caveats I've alrady noticed? It's a really bad thing if the parser responds in a way different way, than you expect.

Quote
Human: are you okay?
ALICE: Don't I look like it?
Human: ASDASDASD
ALICE: Can you speak any foreign languages?
Human: ASDASD
ALICE: Do not ask me any more questions please.
Human: ASDASDASDASD
ALICE: I've lost the context, unknown person . Are we still on ASDASD ?

This is from a chatterbot conversation
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)

tzachs

Well, I'm not sure that I fully understand the problem, but if you want only "idiot" to be the answer then you should replace
Code: ags

if (txtxwordy.Text.Contains(GetTranslation("idiot"))!=-1) {//If player says idiot.

with
Code: ags

if (txtxwordy.Text.CompareTo(GetTranslation("idiot"))==0) {//If player says idiot.

Dualnames

Quote from: tzachs on Sat 23/01/2010 16:50:47
Well, I'm not sure that I fully understand the problem, but if you want only "idiot" to be the answer then you should replace
Code: ags

if (txtxwordy.Text.Contains(GetTranslation("idiot"))!=-1) {//If player says idiot.

with
Code: ags

if (txtxwordy.Text.CompareTo(GetTranslation("idiot"))==0) {//If player says idiot.


It works fine as it is, it just caus the caveats I mentioned.
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)

monkey0506

But you're looking to get rid of the caveats which is why tzachs suggested using CompareTo instead of Contains.

Dualnames

#4
Quote from: monkey_05_06 on Sat 23/01/2010 17:29:06
But you're looking to get rid of the caveats which is why tzachs suggested using CompareTo instead of Contains.

Sorry, bad vision. Nice suggestion there tzachs! This will allow players to make small spelling mistakes?

EDIT: thanks, I'll come up with a different situation on those parsers, so keep an eye. :D
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)

Atelier

For my game I just added common typos as synonyms. Word's auto-correct list if full of them, so it won't take you long to copy them down.

Dualnames

Quote from: AtelierGames on Sun 24/01/2010 09:14:57
For my game I just added common typos as synonyms. Word's auto-correct list if full of them, so it won't take you long to copy them down.

I'm not using the parser feature of the AGS at all. Since you have the experience (you're working on a text-adventure game in AGS), care to give me a headstart?
I've played a little with the synonyms and all. Is it worth it more than using my check?
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)

Atelier

#7
Yes, the in-built parser is more efficient and easy to control. I suppose it depends whether you will use the parser a lot. What are you making?

Dualnames

Quote from: AtelierGames on Sun 24/01/2010 14:12:33
Yes, the in-built parser is more efficient and easy to control. I suppose it depends whether you will use the parser a lot. What are you making?

There are just points in the game that 'require' text parser, one is this one and another is one you have to carve some words. It's for Hitchhhiker's.

Wondering how do you handle irrelevant responses to your game?
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)

SMF spam blocked by CleanTalk