insert text box problem

Started by vaultdweller, Wed 15/04/2009 12:03:03

Previous topic - Next topic

vaultdweller

I have a GUI - insert text box. What I want to do is this: Player enters text fe.: "He has a big home." Now I want AGS to recognize what words did the player entered. For example if the player entered words "house" and "big" among other words in the sentence, script1 will start. If he entered only word "big" i want script2 to start and if he only entered "house" script3 will take place.

Thank you!

Scummbuddy

Have you looked through the AGS Help Documentation for the "text parser"?. That would be incredibly beneficial for what you want to do.

If this is the only time you will be having the user input data, it may be overkill, and you could have a bunch of text buttons on a gui for the user to select from depending on the puzzle type.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

vaultdweller

I plan to have this GUI throught the whole game. Only by using this GUI the player will control the game, so I need to use it multiple times. If the text parser will help, I will try that.

Dualnames

String.IndexOf could be of use.
Assign textbox's text to a string first
example:

String input=txtbox.Text;
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)

vaultdweller

#4
I dont know what is that StringOf function, but thats probably cuz I run AGS 2.72 (cuz i like it). Here is what I did so far. I used the text parser and I have a GUI with text box. Now I can type "he is good" and my script will run, but if I write "good he" or "he good xyxyx" than nothing happens. Is there a way I can make this work?
Very simply put: If there will be the right combination of words in the input box, than something will happen. For example:

A = he, B = good, C = bad

A B - script 1
B A - script 1
A B and XY (any other word that is not supposed to be in the combination like C or any word not in the parser) - scrpit 1
A - script 2
A XY - script 2
B - script 3
B XY - script 3

At work:
"He is a good person." = A x x B C - script 1
"A good person he is." = x B C A x - script 1
"Very good." = "x B" - script 3

vaultdweller

#5
I got this far:

  String input = enter.Text;

  if (input.Contains ("He good bad")) {
      Display ("Do this.");
    }
 
    if (input.Contains ("good")) {
      Display ("Do something else.");
    }
 
Now I can write: "He is good but very bad as well" and it works (almost).

Problems: If I write a sentecne containing the word "good", both messages will display.
If I write the exact case: "He good bad," nothing will happen.
Any help PLEASE???

Khris

You need to look up the text parser functionality in the manual.

vaultdweller

I did and tried it. It didnt work. I think I need an exact script that I could use.

Khris

Did you read this section?

What did you try?
What didn't work?
Did you add the words to the word list properly?

Spelling out some code might solve this little problem for now, but you'll be back here in no time if you don't try to work out things for yourself.

Trent R

QuoteProblems: If I write a sentecne containing the word "good", both messages will display.
Can be fixed easily, read the tuts on scripting and scripting syntax.

QuoteString input = enter.Text;

  if (input.Contains ("He good bad")) {
    Display ("Do this.");
  }
 
  elseif (input.Contains ("good")) {
    Display ("Do something else.");
  }


But seriously? You're trying too hard and overthinking the problem. Read the section on the text-parser that Khris linked, and if need be, upgrade to AGS 3.x


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

vaultdweller

#10
Dont get me wrong guys, I was trying to solve this problem myself in a hundred ways. Now I think I am only going to use the text parser function. I only have last remaining problem:

If the player types in a word not found in the dictionary (parser), nothing will happen. I know I should use the SaidUnknownWord function or the anyword function or the rol function, but I dont know how. Please tell me.

My solution so far is a bit clumsy:

  if (Parser.Said("rol he rol good rol")) {
    if (GetGlobalInt(1)==0) {
    gComand.Visible = false;
    character[F].Say ("My heart is so big anything can fit inside.");
    SetGlobalInt (1, 1);
}
}

Thx

SMF spam blocked by CleanTalk