Get input in Gamebook

Terrence
Hi everyone,

How do I make Get input repeat until the player enters the correct input?

For example, if I want the player to type in the word boxcar before I call a function, I can create Get input, and I can say, if result = boxcar...

But how do I make it repeat when the player types in anything else?

Thanks,

T.

jaynabonne
Put the "get input" in a function. Then if they don't type the right answer, call the function again. Like:

<function name="GetAnswer">
get input {
if (result = "boxcar") {
// Do the script for the right answer.
} else {
msg("Try again!")
GetAnswer
}
}
</function>

Of course, I'm sure you already know you have to turn on the command prompt to let the player actually type the answer... ;)

Terrence
Yes, after my few days experience I'm a Quest programming wizard. Not.

After looking at your code, I added quotation marks to boxcar. Now it works.

Why does it have to have the quotation marks?

jaynabonne
Because it's a string. :) Without quotes, it would refer to an *object* named boxcar, which would not match the string "boxcar" the player has input.

Terrence
Very nice. Thank you, Jay.

May I ask one last related question?

I can output a message, for example

A hobo climbed into a

Then I can Get input. In this case "boxcar".


Is it possible in Gamebook to do the following

A hobo climbed into a <Get input "boxcar>, and was quickly <Get input "ushered"> out.


In other words, can I use Gamebook's built in features to create a fill in the blanks sentence that then calls a function if all the blanks are filled in correctly?

The humble attempts I've made give an error for using multiple Get inputs at once, and also break the sentence after the first Get input, with the text box below instead of inline.

jaynabonne
What you're describing is more like a form. Quest has a single command prompt which always goes at the bottom. You could create (via HTML and CSS with Javascript handlers) your own input controls and manage them all yourself. Since Quest supports general HTML, that is possible, but I suppose that's not what you meant by "built in features". :)

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums