Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

Sugarcube 2.7.0 plucking random questions from an object database and matching them to answers

$
0
0
Hello all,

I'm working on a sugarcube game where the goal is to provide a "quiz arena." In this arena, I'd like the player to be asked random questions, have to answer them before moving on, and have those answers checked one at a time. To do this, I created an object in my StoryInit passage:
<<set $arenaobjects to {
	Questions : {
		q1 : "What is the first class in session 1?",
		q2 : "How many computer classes are there during session 2?",
		q3 : "How many students are in Reading 4 during session 1?"
	}
	Answers : {
		a1 : "Writing" or "writing",
		a2 : "4" or "four" or "Four",
		a3 : "12" or "twelve" or "Twelve"
	}
}>>

I thought about doing this as two arrays instead of two object properties within $arenaobjects, but I'm not sure if that would be better or worse.

The end result I'm trying to achieve is to have a tile display a random question and a textbox, and then know which answer to expect in that checkbox, based on which question was displayed at random. I've worked the above into the StoryInit tile, but am not sure which direction to go in to print the question and corresponding answer at random.


Viewing all articles
Browse latest Browse all 1844

Trending Articles