A multiple-choice game conundrum


This is my first time venturing into Twine, Harlowe 2.1.0 (not sure if there’s a more appropriate version). I’m a complete noob at this and a fiasco at programming. Nevertheless, I’m trying to create a quiz, similar to the “Millionaire” game show, for educational purposes.

So, here’s the plan:

10 random multiple-choice questions (4 alternatives each) going like this:

(link-goto: “First question”, (either: “q11”, “q12”, “q13”))

If the answer’s right, move on to the next question. And if not, game over.

However, I wanted to add some flavour to it:

(1) the player can skip a question no more than 2 times

If he wanted to skip question “q11”, for instance, the “Skip this question” button should lead him randomly to “q12” or “q13”.

Moreover, I wish the “Skips” stats were displayed at the bottom.

(2) the player can get a hint no more than 2 times

For example, if the player gets stuck, he may use a hint with the “Get a hint” button. Then 2 of the 3 wrong answers are randomly deleted.

I’d also like the “Hints” stats to be displayed at the bottom.

Please, how do I solve (1) and (2)?
I’d be ever so grateful for your help!
Thank you! Cheers!

as a newbee myself,
I dont know if it is possible to use a variable as a passage name, I tend to believe the answer is no.

But for your question, I came up with a solution like below:

(set:$arrary to (a:))

(set:$q11 to (dm:"blah blah blah",'a'))
(set:$q12 to  (dm:"blah blah blah blah blah",'b'))
(set:$q13 to  (dm:"blah blah blah blah blah blah blah ",'c'))

(set:$arrary to it +(a:$q11,$q12,$q13))

|rd>[(set:$count to (random:1,3))]<!---number based on how many of your questions-->
(if:$dump contains $count)[(rerun:?rd)]
(set:$rightanswer to (datavalues:$arrary's $count)'s 1 )

(link-repeat:'skip')[(set:$skip to it +1)
(set:$dump to it+(a:$count))

(set:$hint to it +1)
(print: 'the right answer is'+$rightanswer)


(print:(datanames:$arrary's $count))

(link:'a, blah blah')[(set:$answer to 'a')(show:?result)(hide:?question)]
(link:'b, blah blah blah blah')[(set:$answer to 'b')(show:?result)(hide:?question)]
(link:'c, blah blah blah blah')[(set:$answer to 'c')(show:?result)(hide:?question)]
(link:'d, blah blah blah blah blah')[(set:$answer to 'd')(show:?result)(hide:?question)]

(if:$answer is  $rightanswer)[
you are right!
(set:$dump to it+(a:$count))
(link:'next question')[(rerun:?main)]](else:)[game over


I believe there is huge space to improve the code, but that’s what I can came up with anyway

if you find better solution, please paste here so I can learn how to optimize my code, thanks!

1 Like

Wow! It will take me some time to sort that code out. But I hope to feed you back soon. Thank you very much for your help! Cheers!