Anyone seen some code to have a NPC ask a riddle and have an inputbox for the answer ?
Yeah, once.
...
Oh, you want to see it too?
You just need to use the InputBox command (obviously), and StrComp (or StrCaseComp) to check the response, e.g.:
DisplaySpeech (NPC, "I am soft, yet I am firm,");
DisplaySpeech (NPC, "I am coloured, yet I am clear,");
DisplaySpeech (NPC, "I am Jelly.");
DisplaySpeech (NPC, "What am I?");
string answer;
InputBox ("What am I?", answer);
DisplaySpeech (EGO, "Are you %s?", answer);
if (StrCaseComp ("Jelly", answer) == 0) { // Got right answer - would accept 'Jelly' or 'jelly'
DisplaySpeech (NPC, "Yes. Yes I am.");
// Or whatever
}
else { // Wrong answer
DisplaySpeech (NPC, "No I'm not, try again.");
// Or whatever
}
(Written for 2.6, but easy enough to change to 2.7)
Thanks Ashen . I still use 2.6
DisplaySpeech (NPC, "I am soft, yet I am firm,");
DisplaySpeech (NPC, "I am coloured, yet I am clear,");
DisplaySpeech (NPC, "I am Jelly.");
DisplaySpeech (NPC, "What am I?");
string answer;
InputBox ("What am I?", answer);
DisplaySpeech (EGO, "Are you %s?", answer);
if (StrCaseComp ("Jelly", answer) == 0) { // Got right answer - would accept 'Jelly' or 'jelly'
DisplaySpeech (NPC, "Yes. Yes I am.");
// Or whatever
}
else { // Wrong answer
DisplaySpeech (NPC, "No I'm not, try again.");
// Or whatever
}
Just FYI, you forgot a parenthesis. ;)
Deliberate mistake. Just keeping y'all on your toes.
Honest.
(Heh heh heh, smooth...)
Jeez, you've got good eyes, I just spent 5 minutes trying to figure out where from. Anyway, I doubt Candle (or anyone else) is likely to copy-paste that exact code, so it's no big thing.
Heh. ;D I noticed it the first time I was reading through. ;D
And BTW, I would have copied and pasted and edited. :D :P :D
Not trying to be perfect or anything, I mean, I know I make enough mistakes, just trying to help out. ;)
Edit: I just noticed that the quote takes the formatting away. I always forget about that.