choose many answers from a list
spook1
09 Nov 2013, 16:03In my game I am trying to set up a list of answers, from which the players must choose the correct ones.
Is there a simple way to do this?
( I want the player to look at a mivie and afterwards list the four main subjects covered.)
I intend to present the player with a list of 10 subjects, friom which the 4 correct ones must be identified.
any suggestion?
Is there a simple way to do this?
( I want the player to look at a mivie and afterwards list the four main subjects covered.)
I intend to present the player with a list of 10 subjects, friom which the 4 correct ones must be identified.
any suggestion?
Liam315
09 Nov 2013, 16:22You can use the "Show a menu" function to display the list of 10 possibilities. Then in the script that follows use an "if" or "switch" script to define what happens for each choice.
When making the choices, it is easiest to define them as a new string list first.
e.g. For a question with 4 options and 1 correct answer you would have something like:
When making the choices, it is easiest to define them as a new string list first.
e.g. For a question with 4 options and 1 correct answer you would have something like:
candidates = NewStringList()
list add (candidates,"Option 1")
list add (candidates,"Option 2")
list add (candidates,"Option 3")
list add (candidates,"Option 4")
ShowMenu ("Which of the following is correct?", candidates, false) {
if (result = "Option 1") {
msg ("Yay! You got it right.")
}
else {
msg ("Incorrect. Better luck next time.")
}
}
Liam315
09 Nov 2013, 17:00Choosing multiple answers from the same list is a bit trickier. Assuming you'll want to remove options that have already been chosen, you'll be using the same list 4 times so you must define the string list that contains all the candidates and answers in an object i.e. not within the script that you'd be running.
Here is an example. The following would be a function called ThisFunction. You would have to have an object called "box" that exists and create custom attributes called "candidates" (set as a string list containing the possible answers), "answers" (a blank string list), and "correctanswers" (containing the 4 correct answers).
I'm not sure what features of Quest you are and aren't familiar with, so if you have trouble with any part of the script just let me know and I can explain it in more detail. And if it doesn't quite do what your after then it can be modified easily enough until it does.
I've attached an example game file that you can look at to see how it works. If you play the game and type "test" the function will run and show it in action. You can also see how I've added the attributes to the "box" object.
Here is an example. The following would be a function called ThisFunction. You would have to have an object called "box" that exists and create custom attributes called "candidates" (set as a string list containing the possible answers), "answers" (a blank string list), and "correctanswers" (containing the 4 correct answers).
ShowMenu ("Which of the following are correct?", box.candidates, false) {
list remove (box.candidates, result)
list add (box.answers, result)
if (ListCount(box.answers) < 4) {
ThisFunction
}
else {
score = 0
foreach (item, box.answers) {
if (ListContains(box.correctanswers,item)) {
score = score + 1
}
}
msg ("You got " + score + " out of 4 correct.")
}
}
I'm not sure what features of Quest you are and aren't familiar with, so if you have trouble with any part of the script just let me know and I can explain it in more detail. And if it doesn't quite do what your after then it can be modified easily enough until it does.
I've attached an example game file that you can look at to see how it works. If you play the game and type "test" the function will run and show it in action. You can also see how I've added the attributes to the "box" object.
spook1
09 Nov 2013, 21:56This is great!
Just what I need. It works like a charm, only,
after I took the quiz, and I take it again, the removes candidates are not in the list anymore.
Can I reset this somehow without restarting the whole game?
Just what I need. It works like a charm, only,
after I took the quiz, and I take it again, the removes candidates are not in the list anymore.
Can I reset this somehow without restarting the whole game?
Liam315
10 Nov 2013, 01:20You can, just add these two lines under the "you got x out of 4" message.
This will change the order that the options are displayed in. If you would prefer to keep the options in the same order each time, simply use the StringListSort function when printing the menu. i.e.
box.candidates = ListCombine(box.candidates,box.answers)
box.answers = NewStringList()
This will change the order that the options are displayed in. If you would prefer to keep the options in the same order each time, simply use the StringListSort function when printing the menu. i.e.
ShowMenu ("Which of the following are correct?", StringListSort(box.candidates), false) {