looping problem i cant jump to another label
Posted: Thu May 06, 2021 1:20 am
im trap in the loop in my quiz game
how can i jump to next label?
im trying to make a quiz 1-10 multiple choice and 11-10 is true or false.
and when in in the category2 the true or false, its always back to category 2 like infinite loop. i dont know what logic should i use to make it.
is there any other way to fix this?
here the quiz code its working, problem is the loop:
anyone can help me ? thank in advance
how can i jump to next label?
im trying to make a quiz 1-10 multiple choice and 11-10 is true or false.
and when in in the category2 the true or false, its always back to category 2 like infinite loop. i dont know what logic should i use to make it.
is there any other way to fix this?
here the quiz code its working, problem is the loop:
Code: Select all
$ q_list = [
{"question": "It is an electronic device that manipulates information, or data. It has the ability to store, retrieve, and process data.?", "answer": [ ["Computer", "right"], ["cpu", "wrong"], ["modem", "wrong"], ["internet", "wrong"] ], "category": "multiple choice"},
{"question": "is the primary component of a computer that processes instructions. It runs the operating system and applications, constantly receiving input from the user or active software programs. It processes the data and produces output, which may stored by an application or displayed on the screen.?", "answer": [ ["cpu", "right"], ["computer", "wrong"], ["motherboard", "wrong"], ["internet", "wrong"] ], "category": "multiple choice"}
]
$ q_listtof1 = [
{"question": "After adding and removing any other system components, make sure that you unplug your power supply. ", "answer": [ ["False", "right"], ["True", "wrong"] ], "category": "True or False"},
{"question": "After starting the installation, read carefully the documentation and procedures on any hardware and software settings that may be required", "answer": [ ["False", "right"], ["True", "wrong"] ], "category": "True or False"}
]
$ q_result = [] ## the question that is asked of the quiz store in here
$ q_resulttof1 = []
# game variables
$ right_answers = 0 # result of quiz game
$ wrong_answers = 0 # result of wrong answer
$ quiz_length = 10 # number of questions in one game
$ quiz_length1 = 10
$ unlocked = [right_answers]
$ q_asked=0
$ passingScore = 15
# let's choose some questions to play with
$ q_to_ask = renpy.random.sample(q_list, quiz_length) # list of questions to ask in one game
show screen countdown ## timer
label quize_game: # game loop
$ a = q_to_ask.pop() # pick the question (it will be removed from the list)
python: # let's shuffle answers
b = []
for q in shuffle_answers (a["answer"]):
b.append((q[0], q)) # (answer to show, [answer, 'right/wrong'])
# the question
$ narrator("Category - {}\n\nQuestion - {}".format(a["category"], a["question"]), interact=False)
# the answers - result will be the chosen answer
$ renpy.block_rollback()
$ res = renpy.display_menu(b)
$ result = res[1] # ("right"/"wrong")
$ answer = res[0] # answer (text)
# evaluate the result
if result == "right":
$ right_answers += 1
else:
$ wrong_answers += 1
# store the question and chosen answer in q_result
$ q_result.append([a["question"], answer, result])
$ q_resulttof1.append([a["question"], answer, result])
$ q_asked += 1
if q_to_ask: # if we still got questions to ask
jump quize_game
doy "get Ready for the test II{p}Category : True or False" ### this is the 2nd category #####
$ q_to_ask = renpy.random.sample(q_listtof1, quiz_length1) # list of questions to ask in one game
jump quize_game ###### this is my problem if how can i jump to endofquiz label? if i change it to endofquiz category 2 will not display.
label endofquiz:
if [right_answers] == [quiz_length]:
stop music fadeout 1
jump perfect_score
if [right_answers] < [passingScore]:
stop music fadeout 1
jump zero_score
else:
stop music fadeout 1
hide screen countdown
doy "Your score is = [right_answers] out of [quiz_length]"
doy "Good job! %(player_name)s you passed the 1st level.{p}You have unlocked the 2nd leveL, the SET-UP COMPUTER NETWORK"