Twine Version: 2
[also choose a Story Format tag above]
Hi there,
I am trying to create a quiz. It will have ~100 multiple choice questions, each in its own passage, across 5 domains designated by Tags.
When the user initializes the game, I want to select 5 random passages from each domain. I then want the the user to move through the randomized passages, domain by domain.
As proof of concept I have set up one domain with passages that should simply link to the next passage. I have a start page that works correctly, getting the user to a random question.
However I get Error: cannot execute macro <<goto>>: Story.has title parameter cannot be undefined
when I click to the next passage.
Here is my Start passage:
:: Start
<<set $geographyQuestions = Story.lookup("tags", "Geography")>>
<<set $selectedGeography = $geographyQuestions.randomMany(5)>>
<<set $allQuestions = [].concat($selectedGeography)>>
<<set $currentQuestionIndex = 0>>
<<set _firstQuestionTitle = $allQuestions[$currentQuestionIndex].title>>
Begin the quiz!
[[Start Quiz->_firstQuestionTitle]]
This works fine. I go to a random passage tagged [geography
]`.
Here is what the passages currently look like:
:: Geo_Q1 [Geography]
This is test passage 01 . [[Next Question->NextQuestion]]
Here is my nextQuestion.tw
passage. I suspect this is where my problem lies:
:: NextQuestion
<<set $currentQuestionIndex+1>>
<<if $currentQuestionIndex < $allQuestions.length>>
<<goto $allQuestions[$currentQuestionIndex]>>
<<else>>
You've completed the quiz! [[Back to Start->Start]]
<</if>>
I have confirmed all my passages exist. They are tagged properly (just 6 passages with the same content as above, just different numerals for example :: Geo_Q2 [Geography]
).
It looks like for whatever reason I am not getting the next passage’s title param and throwing an error. Any ideas?
Thank you!