Workaround to avoid repeat trivia questions in a table?
Hello,
I realize that in order to avoid repeat trivia questions, we would need writable tables. Having said that, has anyone thought of a workaround? ( I've been trying to mix TShirtBooth's trivia template and his video on "Random Numbers No Repeat" so that I would at least not have two repeats in a row, but I haven't figured that one out yet.) The ideal, of course, is to ask a question once and never again. Any idea would be appreciated.
Thanks (and kudos to TSB!)
Eli
I realize that in order to avoid repeat trivia questions, we would need writable tables. Having said that, has anyone thought of a workaround? ( I've been trying to mix TShirtBooth's trivia template and his video on "Random Numbers No Repeat" so that I would at least not have two repeats in a row, but I haven't figured that one out yet.) The ideal, of course, is to ask a question once and never again. Any idea would be appreciated.
Thanks (and kudos to TSB!)
Eli
Comments
1) Save the last question to an attribute (LastQuestion)
2) Query the table for a random question.
3) Compare the value of the new random question to LastQuestion. If they are the same, go back to step 2. If they are not the same, display the new random question.
4) Repeat steps 1-3 until the game ends.
Hope that helps.
- Jeff
http://www.mediafire.com/?j2vv9zv8joy1m4y
Hope this helps!
RThurman
Eli
To get another question that is not a repeat of the last question, you could just use a Change Attribute behavior to do:
Change Attribute game.SelectedQuestion to ((game.SelectedQuestion-1+random(1,tableRowCount(yourTable)-1))%tableRowCount(yourTable))+1
This should give you any other row from your table and also make sure that the selected number is not 0(since table rows and columns start at 1).
Here is a demo file:
http://www.mediafire.com/?l61nenxflza2b1a
The demo isn't pretty. But it is functional. (Its a demo, after all, and not a template.)
This was interesting to figure out. Its my first foray into using a table in GS. Tables will help immensely when they are fully read/write capable.
Hope this helps!
RThurman
Smething like:
Pick a randon question
Compare with all arrays positions
If yes, back to begin and take another question
If no, store question number in array and show question