Trying to Understand Screens

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
User avatar
Westeford
Regular
Posts: 151
Joined: Mon Jun 19, 2017 4:43 pm
Completed: 12 Hours to Die
Projects: Project Premonition
itch: westeford
Location: United States
Contact:

Trying to Understand Screens

#1 Post by Westeford »

Chances are I might figure this out the next day, but here we go. I'm trying to figure something out about screens.
What I'm trying to do is create a screen that will be called whenever the player is prompted a question that requires them to present evidence.
I'm a little fuzzy on the details on how this screen works. It uses classes to sort give each item a name, description, and thumbnail. So that when an item is selected, it shows the description and thumbnail.

So when using this first I call the screen with the following.

Code: Select all

call screen evidence("How do we make this screen usable?")
What I want to do is have the player select an item from the list then press the "present" button that will return back to where it was called. Afterward I use an if statement to determine whether the player presented the right piece of evidence.

Code: Select all

#Class code
init python:
    class Item():
        def __init__(self, name, desc, pic):
            self.name = name
            self.desc = desc
            self.pic = pic
            
#Screen code
screen evidence(question):
    imagemap:
        ground "UI/evidence_screen.png"
        hotspot (1176, 604, 85, 100) action Return
    text question ypos 603 xpos 149 size 40
    fixed:
        xysize (995, 556)
        xalign 0.5
        yalign 0.1
        vpgrid:
            default selected_item = None
            cols 1
            spacing -4
            draggable True
            mousewheel True
            scrollbars "vertical"
            xpos 0
            ypos 0
            side_xalign 0.0
            xysize (400, 558)
            for evidence_item in evidence_list:
                textbutton evidence_item.name xysize (385, 50):
                    bottom_margin 10
                    right_margin 5
                    left_padding 25
                    text_size 30
                    text_color "fff"
                    background "#222"
                    hover_background "#f00"
                    selected_background "#960000"
                    action (SetScreenVariable(name='selected_item', value=evidence_item))

        
        #Thumbnail
        vbox:
            yalign 0
            xpos 400
            xysize (500, 300)
            vbox:
                if selected_item:
                    add selected_item.pic
                    yalign 0.5 xalign 0.5 
                else:
                    add "in_blank"
                    yalign 0.5 xalign 0.5 
                    
                
        #Description
        frame:
            xpos 400
            background "in_frame"
            yalign 1.0
            xysize (595, 256)
            viewport:
                if selected_item:
                    text selected_item.desc size 20
                else:
                    pass
My thoughts is that I need to add some way for this screen to do something like this.

Code: Select all

$ evi = "Value" #Probably a unique number I can associate with the corresponding item.

#I've tried testing it with something like this, but it never returned a usable value.
$ evi = selected_item.name
I guess what I'm asking is how can I change the value of evi in the screen?

Sorry if I'm rambling or not making sense. I appreciate appreciate any suggestions on my approach.

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Trying to Understand Screens

#2 Post by Kia »

I think you can use return value for that: https://www.renpy.org/doc/html/screen_a ... tml#Return

Post Reply

Who is online

Users browsing this forum: No registered users