Medical Simulator: Using Screen to create a menu

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
OngThanin
Newbie
Posts: 1
Joined: Tue Apr 24, 2018 6:10 am
Contact:

Medical Simulator: Using Screen to create a menu

#1 Post by OngThanin »

Hey guys, sorry if this has been answered before on this forum but I haven't quite been able to figure it out myself. I'm trying to create a medical scenario simulator, and am having trouble with the last part where the player produces a diagnosis based on the consultation so far.

My goal is to have a screen with a number of buttons, and the player will select variables that they believe is related to the diagnosis. There'll be multiple possible diseases, and each with their own set of answer key. The player will have the option of choosing all the different diseases, and the screen is a way for them to justify their choice (they choose which of the patients factors are related to their diagnosis).

The disease name will be a string, and the chosen_answer will be a list of boolean values that I'll compare from the answer key once the player selects the last button, "That's All".

I've just included two of the reasons for the diagnosis here but in the actual program there'll probably be at least 12.

Code: Select all

screen justification(disease,chosen_answer):
    zorder 100
    modal True
    frame:
        xalign 0.5 ypos 10
        vbox:
            text "Why do you think this is [disease]?"
            textbutton "Demographic":
                action SetVariable("chosen_answer[0]", True)
            textbutton "Site of Pain":
                action SetVariable("chosen_answer[1]", True)
            textbutton "That's all":
                action [Hide("justification", transition=None)]

Code: Select all

show screen justification(disease=disease, chosen_answer=chosen_answer)
And this is how I display the screen. The issue I've been having is that the following error:

Code: Select all

File "renpy/common/00action_data.rpy", line 50, in get_selected
    return getattr(self.object, self.field) == self.value
AttributeError: 'StoreModule' object has no attribute 'chosen_answer[0]'

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Medical Simulator: Using Screen to create a menu

#2 Post by philat »

Problem is you're trying to change the value of an item in a list. I would probably use a dictionary. https://www.renpy.org/doc/html/screen_a ... ml#SetDict

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]