How to make a screen?

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
Bartulisica
Regular
Posts: 93
Joined: Sun Aug 30, 2015 5:11 am
Organization: ArizonaIdentities
Location: Croatia
Discord: ArizonaIdentities
Contact:

How to make a screen?

#1 Post by Bartulisica »

Hello fellow VN creators and fans.
I'm still new to Ren'Py, so I have a question.
I'm not sure if someone already asked, but I looked everywhere, on this page
on wiki, even some blogs related to this and I can't find the script explaind well enough for me to understand it.
So, I'm trying to create an inventory screen (nothing too complicated for now, just a button and a popup screen).
Can anyone please write me a script that places a button ingame that will, when clicked, open the screen, and ofcourse define what is needed.
I've been trying whole night with textbutton,imagemap, and screen commands, and I just can't get it right.
I actually managed to manipulate the menu options with imagemap, but in the script.rpy it doesn't work.

One more simple question (so I don't have to put another topic..): if you use action statement, can it be followed with commands like show,hide,play music "x" etc. or does it have to be a specific command compatible with action statement?

Thanks in advance!! :)

User avatar
Evildumdum
Regular
Posts: 191
Joined: Sun Jan 18, 2015 8:49 am
Projects: ApoclypseZ
Contact:

Re: How to make a screen?

#2 Post by Evildumdum »

Edit* rightly pointed out i didnt use correct indentation. Now changed.
Okay, you need to use the show screen instruction:

Code: Select all

label screen_example:
    "Im showing dialogue. Now to bring up the screen."
    show screen screen_example

screen screen_example:
    add example_inventory_picture
    textbutton "Inventory" xpos 0.5 ypos 0.5 action jump("inventory")
Look up textbuttons and imagebuttons. They are much much easier than imagemaps to use.
Last edited by Evildumdum on Sun Aug 30, 2015 4:42 pm, edited 1 time in total.
"If at first you don't succeed, try hitting it with a shoe."

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to make a screen?

#3 Post by trooper6 »

Evildumdum's code is not properly indented and doesn't do exactly what you wanted.

You want a button that brings up a screen.

The button needs to be on a screen. That button's action will be to show a second screen.

This does what you want. But you should also study the screens already defined in your game's screens.rpy file--it'll give you a bunch of models of working screens.

Code: Select all

screen button_screen():
    frame:
        xalign 1.0
        yalign 0.0
        textbutton "Inventory" action If(renpy.get_screen("inv_screen"), Hide("inv_screen"), Show("inv_screen"))
        
screen inv_screen():
    frame:
        vbox:
            text "Inventory"
            text "-----"
            text "You have a shirt."

# The game starts here.
label start:
    show screen button_screen()
    "Click on the button to show your screen. Click on it again to hide it."
    "game over."
    
    return
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Bartulisica
Regular
Posts: 93
Joined: Sun Aug 30, 2015 5:11 am
Organization: ArizonaIdentities
Location: Croatia
Discord: ArizonaIdentities
Contact:

Re: How to make a screen?

#4 Post by Bartulisica »

Thank you, both.
This is just what I needed, simple inventory I can have fun with!

If I can ask just one more thing..
How do I show inventory items inside it. For example:

Code: Select all

         $ items = []
         $ money = 0
         ##########
         screen inv_screen:
             frame:
                 vbox:
                      text "Inventory: "
                      text "You have %(items)d"
This isn't working right now, so what am I forgeting?

Post Reply

Who is online

Users browsing this forum: Google [Bot]