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!
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.
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.
String.IndexOf could be of use.
Assign textbox's text to a string first
example:
String input=txtbox.Text;
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
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???
You need to look up the text parser functionality in the manual.
I did and tried it. It didnt work. I think I need an exact script that I could use.
Did you read this section (http://www.adventuregamestudio.co.uk/manual/TextParser.htm)?
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.
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
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