Random input text

Hi!

Back in the days of the C64, I used to enjoy having a randomly called command for the player input. So, instead of just something like:

"What now?"

It would display a random question from several strings, e.g.

"What Now?"
"Make your move..."
"You decide what to do next..."
"Go ahead:"

That kind of thing.

Is there a way to do this in Quest? I hoped it would be as simple as changing the string text in the command field to a string list, but it simply displays the full complete text, with semicolons and everything.


Is there a way to do this in Quest? I hoped it would be as simple as changing the string text in the command field to a string list, but it simply displays the full complete text, with semicolons and everything.

You'd need to change it each turn, probably using a turnscript.

You'd have your turnscript pick a string and then set it on the UI.

If you are using a textbox command bar, that would look like:

prompt = PickOneString (Split ("What Now?;Make your move...;You decide what to do next...;Go ahead:"))
JS.SetInterfaceString("TypeHereLabel", prompt)

If you're using a prompt, it would be:

prompt = PickOneString (Split ("What Now?;Make your move...;You decide what to do next...;Go ahead:;What\\'s next?"))
JS.eval("$('#txtCommandPrompt').text('" + prompt + "');")

Note that any single quotes or apostrophes in the prompt string would need to be escaped by a backslash to avoid an error message. And the backslash would need to be escaped to avoid Quest trying to parse it, as shown in the example What\\'s next? above. Or you could use asymmetric/smart quotes ( and ), which don't have this problem.

If you want the prompt to include bold, icons, or other formatting, you can change .text to .html and provide any valid HTML string.


Awesome response, thank you!


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

Support

Forums