I'm pretty sure there's a more elegant way of doing this than what I'm about to describe here, but it should work. You will have to get dirty with some python, though:
What you have is a set of labels that you only want to be called once and in a random order, correct? In this case, why not make a list of the labels (as strings) and then shuffle the list at the start of the quiz section (in your example, immediately before the label "questions_start"). random.shuffle(list) (or renpy.random.shuffle(list)) will do an in-place shuffle of the list, randomizing the order of the contents.
After doing this, you'll need to change how you pick the question. Since your list should be randomized at this point, you should do two things:
First, check that the list actually has contents (or that you haven't given as many questions as you want to, in case you don't want to actually give all of the questions). This is actually trivial in Python, just do "if yourlisthere:" as a conditional statement - an empty list will return false, a non-empty list will count as true for that conditional statement. If you have a limit of questions to present, you can add that to the conditional (so, using variables you gave us, the resulting expression would be "if yourlisthere and dj1 < 10")
Second, assuming the previous check was successful (returned True), you simply pop off either the first element or the last element of the list and feed it to either renpy.jump(label) or renpy.call(label, *args, **kwargs), depending on exact implementation. You can also increment the question counter here instead of in the labels themselves. It is the popping that requires us to check if the list is empty or not previously, as without a question limit, it is inevitable that we will pop all items in the list, eventually having an empty list.
hurriedly-written-not-fully-tested code follows:
Code: Select all
#define only two variables since we only need those two...
$ dj1 = 0
$ questionlist = ["question1", "question2", "question3"] # this would be your list of questions.
# ... ... ...
# assume we arrive at questions_start by falling into it, not by jump/call
$ renpy.random.shuffle(questionlist) # shuffle the questionlist
label questions_start:
python:
if questionlist and dj1 < 10:
dj1 += 1 #increment dj1
renpy.jump(questionlist.pop(0)) #takes first item in the list, removes it from the list, and jumps to it
# renpy.jump(questionlist.pop()) #this would take the last item in the list instead of the first.
else: # either we had 10 questions asked already or we have no questions left
renpy.jump("after_questions")
label question1:
"This is question 1"
jump questions_start
label question2:
"This is question 2"
jump questions_start
label question3:
"This is question 2"
jump questions_start
label after_questions:
"Blah"
Another potential advantage of this is you can also add to that list in the middle of the game by utilizing the standard list append method (questionlist.append(x)), insert method (questionlist.insert(i, x)), or extend method (questionlist.extend(L)). x would be a new item to add (in our case, a label as string), i is the index of the location in the list to insert an item (0 is the front), and L would be a list of items to add to the end (in our case, a second list of labels as strings).