Conditions in 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
Pixelgames
Newbie
Posts: 8
Joined: Tue May 10, 2016 6:33 am
Contact:

Conditions in screens

#1 Post by Pixelgames »

Hi!

I've been wondering it there's a simple way to code a simple condition inside a screen in ren'py, like:

Code: Select all

if i == 0:
    vbox xalign 0.99 yalign 0.01:
        imagebutton 1

else:
    vbox xalign 0.99 yalign 0.01:
        imagebutton 2

or, if not, some way to avoid the user to skip through a label with a code like:

Code: Select all

    if i == 0:
        
        show screen 1
        
    else:
        
        show screen 2

Either way, I need to throw a bunch of "$renpy.pause(hard=True)" in this label, to avoid the bug of returning to the main menu.

Hope I explained it well!

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Conditions in screens

#2 Post by Divona »

See Showif Statement. If/Elif would still work fine in Screens also.
Completed:
Image

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: Conditions in screens

#3 Post by trooper6 »

Pixelgames wrote:Hi!

I've been wondering it there's a simple way to code a simple condition inside a screen in ren'py, like:

Code: Select all

if i == 0:
    vbox xalign 0.99 yalign 0.01:
        imagebutton 1

else:
    vbox xalign 0.99 yalign 0.01:
        imagebutton 2

Either way, I need to throw a bunch of "$renpy.pause(hard=True)" in this label, to avoid the bug of returning to the main menu.

Hope I explained it well!
Have you tried making a blank project and just testing out your code idea before asking? Because I just made a screen with if/else just as you described and it worked no problem. So try things out!

Anyway, I want to address your comment about the bug of returning to the main menu. That isn't a bug. That is a misunderstanding of what screens are.

Screens are not the story. They are just UI elements.

This:

Code: Select all

label start:
    show screen move()
    return
is the same thing as doing this:

Code: Select all

label start:
    return
and if you give an empty block it is going to go back to the main menu. Not a bug.

Instead you should work on designing your game differently so that it isn't empty.
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

Pixelgames
Newbie
Posts: 8
Joined: Tue May 10, 2016 6:33 am
Contact:

Re: Conditions in screens

#4 Post by Pixelgames »

Thanks for your answers. :)
The 'showif' statement is what I was looking for! I'm pretty new into ren'py, so I think I still confuse some of the basics.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]