So I'm a total noob to both Python and Ren'Py but I've got a grand idea and I love banging my head against walls so I'm going for it.
In the current section I have a list of 3 subjects, each with 6 brief lectures associated with them. and each lecture has two knowledge check questions. I'm trying to present two random lectures for each subject, then one of the possible four knowledge check questions. I've created a couple of dictionaries for the lectures and the knowledge checks, then created (that word in this situation is a bit strong) a function to call up the lectures and knowledge checks from them. I haven't been able to test the function yet, because of my syntax when trying to call it.
Function (inside a Python block)
Ren'py scene
I'm getting an error that "The call is to nonexistent label 'present_teaching_moment'." I'm sure this isn't the only error I will get, but I've managed to troubleshoot a lot on my own so far, just can't get around this or figure out how to get more detail on it. Any help hugely appreciated.
In the current section I have a list of 3 subjects, each with 6 brief lectures associated with them. and each lecture has two knowledge check questions. I'm trying to present two random lectures for each subject, then one of the possible four knowledge check questions. I've created a couple of dictionaries for the lectures and the knowledge checks, then created (that word in this situation is a bit strong) a function to call up the lectures and knowledge checks from them. I haven't been able to test the function yet, because of my syntax when trying to call it.
Function (inside a Python block)
Code:
def present_teaching_moment(category):
"""
Presents two randomly selected teachable moments from the given category
and then presents a randomly selected knowledge check for one of them.
Args:
category: The name of the category.
"""
import random
# Select two random teachable moments from the category
selected_moments = random.sample(list(teachable_moments[category].keys()), 2)
# Present the selected teachable moments
for moment in selected_moments:
renpy.say(teachable_moments[category][moment])
# Select a random teachable moment for the knowledge check
selected_moment = random.choice(selected_moments)
# Randomly select a question from the knowledge check
selected_question = random.choice(list(knowledge_checks[category][selected_moment].keys()))
Code:
label military_equipment_scene:
$ current_category = "Equipment" # Store the current category
call present_teaching_moment(current_category)
jump military_strategy_scene # Proceed to the next scene