Ren'Py Help with vbox, hbox and screens [Solved]

Harkonnan

Give me chiisana oppai!
Game Developer
Oct 24, 2020
190
329
I'm trying to make an end version screen that will be easy to edit. Basically what I want it to is to find in the code the name, version number and then put any closing comments I choose to add for that version.

I am having trouble understanding how to set it up as I get the "screen" but no text. I've tried many different things and this was the first one that didn't give errors. The more I looked at the documentation the more confused I got. So if you could help me understand how the boxes and screens work in relation to one another while explaining would I did wrong that would be greatly appreciated. I really can't tell if I am defining the screen wrong or the box or if it's a style issue. Thanks in advance to anyone who can help me with this.

This is the current version of the the code I'm trying to use.

Python:
screen end_version:
  
    modal True

    hbox:
        label _("[config.name!t] [config.version]")                   #gets name and version of game
        text _("Type game version comments here.")                    #version comments
      
style end_versoin_label:     
    xsize 375                 
    right_padding 30         
              
style end_version_label_text:
    size gui.text_size
    xalign 1.0
    text_align 1.0
 
Last edited:

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
Okay. A couple of things.

If you are familiar with spreadsheets like MSExcel or GoogleSheets, [hbox] is a table row (well more like a single cell), where each cell's width is normally autosized based on it's contents.

Or put another way, it's a horizontal box that is (usually) only as wide enough to fit the other screen elements within it.

Next... you have a typo already. style end_versoin_label:. "version" is misspelled.

Now on the programming stuff...

While you have style statements to change how things are displayed, those style lines are currently unknown to your screen. Right now, you're assuming that by naming styles to begin with "end_version", that's enough. But it isn't and you need to add a style_prefix statement, so the screen knows which styles to use for this section (or the whole) of the screen.

One other tweak is that your second style is named end_version_label_text. Generally speaking, the name of a style is the prefix + screen_element_type. So in your case, "end_version" + "text" or "hbox" or "label". Whereas you've put "label_text". If you had a vbox:, it's style would be named "end_version_vbox" (unless overridden by another style_prefix statement).

There are some exceptions to this rule, most noticeably screen elements which combine other screen elements, like textbutton: which is both a button and some text and it's style names are tweaked to reflect that.

But now down to the crux of your problem... and this is an educated guess on my part...

A screen definition only creates a screen. It doesn't show it. It's a bit like an image: statement or define or default. They can literally go almost anywhere in the code (which is why most screens go in a separate file like screens.rpy or something like custom_screens.rpy).

I'm guessing you've put the screen inline within your script and you can't explain why RenPy seems to be ignoring it.
Except it's not ignoring it, it's merely processing it during the game startup and waiting for a command to display it.

What I think you are missing is either call screen or show screen.
call screen displays a screen and waits for the player to interact with it.
show screen displays a screen, then immediately continues just leaving the screen there for the player to interact with later.

There's also a screen statement that matters here too. modal True tells RenPy that the player MUST interact with this screen and this screen ONLY, until this screen is closed. It is very common to use modal True with screens designed for use with call screen and very rare for it to be used with show screen.

What I think you're looking for is:

Python:
screen end_version:

    modal True
    style_prefix "end_version"

    hbox:
        label _("[config.name!t] [config.version]")                   #gets name and version of game
        text _("Type game version comments here.")                    #version comments

    textbutton "[ Exit ]":
        xalign 0.5
        yalign 0.5
        action Jump("the_end")

style end_version_label:
    xsize 375
    right_padding 30

style end_version_text:
    size gui.text_size
    xalign 1.0
    text_align 1.0


label start:

    scene black with fade

    "*** START ***"

    call screen end_version


label the_end:

    "*** THE END ***"
    return

I've added an exit button to your screen to just avoid the screen sitting there with no way out of it.

Obviously the positioning and styling of things needs work. Maybe a background image or flat color. But this is the bare bones of what you're trying to achieve.
 
Last edited:
  • Like
Reactions: Harkonnan

Harkonnan

Give me chiisana oppai!
Game Developer
Oct 24, 2020
190
329
Thanks for the quick replies. 79flavors Your explanation seems clear and concise so I'm guessing this is either beyond me or after being up for 20+ hours I'm doing something wrong. I get an end of line expected error for this line.

call screen end_version
I guess if I explain exactly what it is I want to get from this there may even be an easier way. Basically I want this to be the last screen before you click and you are returned to the start screen. I just want the game name, version and my version comments centered in the game window.

Name Version
Comments​

I plan on making a different background image for each release but want this text to be in the same position each release.

Once I get that working I plan on adding clickable images with links for my discord and whatever else I need. But that's for later. I need to get this working first.

Thanks again for all your help. I'm going to try to get some sleep and will check back later. With any luck things will be clearer to me then.
 

Harkonnan

Give me chiisana oppai!
Game Developer
Oct 24, 2020
190
329
Thanks for your help. I now have the screen I wanted. Well I'm till working out some of they styling but you solved my issue so thanks for that.
 
Last edited: