Can anyone help me understand screens? Any input is welcome

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
TheOtherNewGuy
Regular
Posts: 26
Joined: Wed Nov 16, 2016 2:53 am
Contact:

Can anyone help me understand screens? Any input is welcome

#1 Post by TheOtherNewGuy »

Using Ren'Py 6.99.11.1749

Hi all. Starting from the ground up here, not even standing, face is pretty much flat on the ground and i'm breathing in dirt. I was wondering If you all can help me understand screens. I always check out the documentation first before I ask stuff, but I'm not experienced enough with coding to bridge the gap between "These are the more complex things that Ren'Py can do", and "This is exactly what you need to type in your script".

Right now I just want to make a simple screen that makes a button pop up on the screen. I click it and it goes back to whatever I'm doing.

Anyway, from what I read about screens, I got that you create them by typing something like

"My_Screen():"
---------------------------------------------------------------------------------------
by the underscore im assuming that there can be no spaces in a screen name.
parenthesis are used to contain arguments?
but you need parenthesis even without arguments?
Lastly the screen name has to end with a colon?
------------------------------------------------------

as far as I know this just tells the script that the screen exists? and to call it you need to type

"call My_Screen"

in the script.rpy?

My first attempt at starting this screen was this. I put this in some random place in my screen.rpy

Code: Select all

screen click_me():
        imagebutton auto "gui/click me_%s.png"
        align .5, .5
        action Return()
I learned a bit about imagebuttons in my second thread, but I got the idea on where to put the lines of code from another thread.

--------------------------------------------------------------------------------------------------------------------------------------------------
I know that in other languages indentation is good for clarity and organization, but here indentations are needed for code to work?
--------------------------------------------------------------------------------------------------------------------------------------------------

I called this test screen using a call statement in my script.rpy

Code: Select all

label start:

    scene bg room

    show eileen happy

    ## These display lines of dialogue.

    "Hello, world."
    
    call screen click_me
This gets my "click me" image to show up but on the top left corner of my screen (wanted it to be centered), and nothing happens when i click it. But yeah any thoughts or information on this would be appreciated. Feel free to nerd out and explain everything in your head.

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

Re: Can anyone help me understand screens? Any input is welc

#2 Post by Kia »

you're almost there ^_^
screens are created like this:

Code: Select all

screen screen_name:
    buttons, images, frames, etc...
-the screen's name should be unique in the whole game.
-parenthesis are not mandatory if you're not passing any variables to the screen.
-there are lot's of things you can add to your screen, see the detailed list here: https://www.renpy.org/doc/html/screens.html
-buttons and timers can have actions, see the detailed list here: https://www.renpy.org/doc/html/screen_actions.html
-indentation of the code is very important in renpy.

Code: Select all

    if tow_is:
        vbox:
            style "say_two_window_vbox"
            if who:
                window:
                    style "say_who_window"
                    text who:
                        id "who"
a good rule of thumb is:
whenever a line is ended a colon, the next related lines should be indented.
imagine every line with colon as a container, anything that goes in it should be indented a bit more than the container.
in the example above "if" contains the "vbox"
"vbox" contains some style and another "if"
that "if" contains a "window"
"window" contains it style and a "text"
and the "text" contains it's "id"

-some times the colon is removed and everything that goes in the object is lined in front of it:

Code: Select all

text "say something" size 30 color "#ff3"
is the same as

Code: Select all

text "say something":
    size 30
    color "#ff3"

TheOtherNewGuy
Regular
Posts: 26
Joined: Wed Nov 16, 2016 2:53 am
Contact:

Re: Can anyone help me understand screens? Any input is welc

#3 Post by TheOtherNewGuy »

thank you kia, this is good info. That one colon just made everything below work.
kia wrote:
a good rule of thumb is:
whenever a line is ended a colon, the next related lines should be indented.
imagine every line with colon as a container, anything that goes in it should be indented a bit more than the container.
in the example above "if" contains the "vbox"
"vbox" contains some style and another "if"
that "if" contains a "window"
"window" contains it style and a "text"
and the "text" contains it's "id"
explaining it like that really helps me out. thank you.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Kia