I'm wanting to have conversations done as a text parser, rather than selecting dialogue options, but I can't quite seem to make sense of the manual. I'm no coder. I understand how to build the text parser and I understand how to build dialogues, I'm just not really sure how to put them together. I've selected the "Show the text parser with this topic" option so I've just got the default text box. Should I make my own to make scripting easier? I have very little idea as to how I should go about this.
It's right there in the manual:
When the player clicks on the textbox option, its contents is parsed and then dialog_request is called, with the topic number as parameter.
I've tested this with a new game and Dialog topic 0:
function dialog_request(int parameter) {
Ã, if (parameter==0) {
Ã, Ã, String badword = Parser.SaidUnknownWord();
Ã, Ã, Display("%s", badword);
Ã, }
}
As expected, this displays the word I've entered, as long as it's unknown to the parser.
What exactly is your problem? Or did that solve it?
Ok, yeah sorry, I was kinda vague. I'll try and be more specific. When the player clicks "talk to [whatever character]" I want the text box to come up. The player would type things which may or may not activate certain dialogues. For instance if they type "hello", character 1 would say "Hi there Steve," and character 2 would say "How's it going hombre?". Ok that's probably a really bad example but it should give you a better idea of what I'm looking for. I did try your code and I'm probably doing it wrong because I couldn't it to work. Thanks for helping, by the way.
Ok, then you won't even need the stuff I wrote about.
Asking strings from the player can be done with a custom GUI, and there's the built in InputBox() (http://www.adventuregamestudio.co.uk/manual/Game.InputBox.htm) function.
So in the talk to character-interaction, you'd use something like this:
String top;Ã, // topic entered by player
String badword;
conv=true;Ã, Ã, // conversation still running?
while (conv) {
Ã, top=Game.InputBox("Tell Steve:");
Ã, Parser.ParseText(top);
Ã, badword=Parser.SaidUnknownWord();
Ã, // word not know by parser
Ã, if (badword!=null) {Ã, Ã, Ã, Ã,Â
Ã, Ã, player.Say("%s", badword);
Ã, Ã, cSteve("What do you mean??");
Ã, }
Ã, // known words
Ã, else if (Parser.Said("hello")) {
Ã, Ã, player.Say("Hi there, Steve");
Ã, Ã, cSteve.Say("How's it going hombre?");
Ã, }
Ã, else if (Parser.Said("candy")) {
Ã, Ã, player.Say("So, do you like candy?");
Ã, Ã, cSteve.Say("Yes, fer sure.");
Ã, }
Ã, // end conversation
Ã, else if (Parser.Said("ciao")) {
Ã, Ã, conv=false;Ã, // while loop won't run again
Ã, Ã, player.Say("Well, see you.");
Ã, Ã, cSteve.Say("Yeah, bye.");
Ã, }
Ã, // known word, but default response
Ã, else {
Ã, Ã, player.Say("%s", top);
Ã, Ã, cSteve.Say("I see.");
Ã, }
}
You can even do this without the parser. Call top.LowerCase(); and then use code like this:
if (top=="hello") {
Ã, ...
}
else if (top=="candy") {
Ã, ...
}
Ok, thanks very much. I've managed to come up with a kind of combination between what you told me and what was in the manual and I'm quite pleased with it. So, thank you.
Glad to have been of some help :)
If the issue is resolved, please add "(SOLVED)" to the thread's title by modifying the first post.
Solved :)