Open ended question help

Hello, I am quite new to programming and I would like to ask if it is possible to create an open ended question. The question would be a prompt where the player can have multiple answers with each answer gaining or losing points. Once the player answers correctly a certain amount of times, a new prompt will be shown and the player will again have to guess multiple answers to move onto the next prompt.

An example for this would be:
Set-up: You wake up in a film studio, the director is looking at you waiting for your next move.
Question/Prompt: The director screams action, what will you do?
Answers: jump (+1 point), lay down (-1 point), flip (+1 point), scream (+1 point), etc.
Results: The player guesses enough correct answers to move onto the next prompt.

How can I go about creating a prompt that accepts multiple answers as well as take scores for each answer that will add up to unlock the next prompt question?

Sound like a guessing game...
But unless you provide clues as to a "correct" answer, it will get a few plays.
This would (could) work in a table-top RPG game, but you would need to pre-think every possible choice before hand.
Something hard to do when it could take about 10% of your choices to get to the next round, then do it all over again for the next question.

Some of what you want is described here:

I'd probably end up making an object for each question. (You could use a dictionary, but Quest's limited support for them is kind of lame). Then have a function which displays the next question, called after each time an answer is given.

A pretty awkward way to allow more than one choice from a menu

If you're allowing the same question more than once, it might be useful to know that you can save and restore a menu. After calling ShowMenu (actually after it, not in the response script) you have the code:

game.savedmenuoutputsection = game.menuoutputsection
game.savedmenucallback = game.menucallback
game.savedmenuoptions = game.menuoptions
game.menuoutputsection = ""

Then in the result script (after handling result for the question) you would do:

game.menucallback = game.savedmenucallback
game.menuoptions = game.savedmenuoptions

to allow the player to pick a second option.
When the player has picked the last option, you would then do:

game.menuoutputsection = game.savedmenuoutputsection
game.savedmenuoutputsection = null

to hide the menu.
If you allow the user to cancel (entering another command instead of choosing a menu option) you would also want to have a turnscript to hide the menu in that case:

if (HasString (game, "savedmenuoutputsection") and not HasScript (game, "menucallback")) {
  game.menuoutputsection = game.savedmenuoutputsection
  game.savedmenuoutputsection = null

If you want to disable options that have already been chosen, you'd want to have a javascript function:

DisableMenuOption = function (section, optionTag) {
  $('#' + section + ' a[onclick$="ShowMenuResponse\',\'' + optionTag + '\')"]').addClass("disabled").off("click");

which you can then call from the question's result-handling script using:

JS.DisableMenuOption(game.savedmenuoutputsection, EscapeQuotes(result))

I'd put together a simple mockup, but there's a few things I'm not so clear on:
You said you want the question to repeat until the player gets a certain number of correct answers. Is that a number of answers, or a number of points, or a number of points excluding negatives?
Do you want to display a result after each option has been chosen, or just ask the question again? Can the player choose the same option twice? (And if not, is the option removed from the menu, or do they just get told not to pick the same one twice?)
Do you want to do something with the score (put it into an attribute maybe?) after the question has finished?

Thank you for all of the responses! These examples are helping out a ton!

To answer your questions mrangel:

  • I would like to have the question repeat (or only asked once if that is possible) until a certain number of points excluding
    negatives is reached.
  • A result should be displayed after an option has been chosen.
  • The player shouldn't be able to choose the same option and if they do, there should be a displayed result telling them they
    can't pick that option again.
  • I would like for the score to accumulate so that it unlocks the next question after you score a certain amount of points
    (example: 5 points = second question, 10 points = third question, 15 = fourth question, etc.)

For the example of saving and restoring a menu, would that be a script placed in the room or would it be located elsewhere? Thanks for your detailed explanation!

Also, would it be possible to just create a list of each answer a player can respond with and have it display a response each time the player uses one of the list answers?

Ah, I thought Pixie had linked you to a tutorial on ShowMenu, so I just posted some bits of code you can add to that, which will allow the player to choose more than one option from the same menu.

It looks like the people who've answered this post have different ideas what you're trying to do. I thought you wanted a question that presents the player with a list of answers to click on. Pixie gave a link to a tutorial that will let the player type an answer, and then check if their input meets one of the options.

Which one is your intention?

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