Is this the right way to set up 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
LiveTurkey
Regular
Posts: 109
Joined: Tue Dec 27, 2016 10:50 pm
Location: Brooklyn
Contact:

Is this the right way to set up screens?

#1 Post by LiveTurkey »

I'm creating a dating simulator and I'm trying to create the imagebutton and the screens but my code feels clunky wrong. I have it working so far but with a lot of hotfixes that shouldn't be there probably.

Is this code right or is there a better way to accomplish all of this?

Code: Select all


label homeroom:
    hide b  #Hot fix number one. Later in the game I show a character. I can't figure out how to hide this character properly. The only      solution is hiding it in the main label. I definitely dont want to start each label by hiding every possible character. 

    if day == 0: # First Day
        p "I should introduce myself to my classmates. I can't be a loner again..."
        call screen homeroom_options
    call screen homeroom_options

screen homeroom_options:
    
    imagebutton: # simple imagebutton for a character. This is working as intended I'm pretty sure. 
        idle "buttons/bethanyg.png"
        hover "buttons/bethanyh.png"
        focus_mask True
        action [Jump ("bethany")]

label bethany:
    show b smile  # This is where I show bethany but then am unable to hide her. 
    b "hey"
    call screen bethany_options
    return

screen bethany_options:
    
    imagebutton:
            idle "backgrounds/transparent.png"
            action [Hide ("bethany_options"), Jump ("homeroom") ] #if the player clicks on not one of the options I jump back to homeroom where you can interact with a separate character. Is it possible to hide the "b smile" in this action? 
            
    imagebutton:                             
            idle "boxes/talkg.png"
            hover "boxes/talkh.png"
            action [Hide ("bethany_options"), Jump ("talkbethany")]
            xpos 500
            ypos 850
                    
    imagebutton:                             
            idle "boxes/flirtg.png"
            hover "boxes/flirth.png"
            action [Hide ("bethany_options"), Jump ("flirtbethany")]
            xpos 800
            ypos 850
            
    imagebutton:                             
            idle "boxes/giveg.png"
            hover "boxes/giveh.png"
            action [Hide ("bethany_options"), Jump ("flirtbethany")]
            xpos 1100
            ypos 850
            
P.S. What's the difference between calling a screen and showing one?

User avatar
justcolorado
Regular
Posts: 47
Joined: Sun Feb 07, 2016 9:32 pm
Completed: Experiment Gone Rogue, Caravan Of Saints, HeartBaked, Hipster Axe
Projects: Iragon
Organization: Repulse.com
Github: coloradostark
Location: Plovdiv
Contact:

Re: Is this the right way to set up screens?

#2 Post by justcolorado »

Code: Select all

label homeroom:
    hide b  #Hot fix number one. Later in the game I show a character. I can't figure out how to hide this character properly. The only      solution is hiding it in the main label. I definitely dont want to start each label by hiding every possible character. 
Try this to clear your characters out.

Code: Select all

label my_label:

     scene my_background_image  #That should clear out the characters and the images but not screens, and sound



I usually put screens in a separate file just to keep things organized.

You asked what is the difference between calling and showing a screen.

I would need to test this to confirm, but I believe when you call a screen you limit the users ability to advance story until they interact with the screen. And when you show it they can still keep reading the story whether or not they interact with the screen.

I didn't see anything wrong with the rest is OK if it is doing what you want. But I had some problems with "focus masks" in the past not building on android. I am not sure if that has been corrected with v6.99.12. I usually just avoid them.
Last edited by justcolorado on Wed Jan 25, 2017 10:02 pm, edited 1 time in total.

User avatar
LiveTurkey
Regular
Posts: 109
Joined: Tue Dec 27, 2016 10:50 pm
Location: Brooklyn
Contact:

Re: Is this the right way to set up screens?

#3 Post by LiveTurkey »

justcolorado wrote: Try this to clear your characters out.
Yep that worked! Thanks.

User avatar
LiveTurkey
Regular
Posts: 109
Joined: Tue Dec 27, 2016 10:50 pm
Location: Brooklyn
Contact:

Re: Is this the right way to set up screens?

#4 Post by LiveTurkey »

Also is there any way to set a variable when the imagebutton is clicked. For example:

Code: Select all

 
    imagebutton:
        idle "buttons/bethanyg.png"
        hover "buttons/bethanyh.png"
        focus_mask True
        $ speaker = "bethany" 
        action [Jump ("bethany")]

    imagebutton:
        idle "buttons/candyg.png"
        hover "buttons/candyh.png"
        focus_mask True
        $ speaker = "candy" 
        action Show ("teacherFirstDay_options")

That doesn't work but is there anyway to make it work ?

User avatar
justcolorado
Regular
Posts: 47
Joined: Sun Feb 07, 2016 9:32 pm
Completed: Experiment Gone Rogue, Caravan Of Saints, HeartBaked, Hipster Axe
Projects: Iragon
Organization: Repulse.com
Github: coloradostark
Location: Plovdiv
Contact:

Re: Is this the right way to set up screens?

#5 Post by justcolorado »

I set variables from buttons on screens it with function calls like this.

Code: Select all

            textbutton "Buy":
                action [ Function(trader.sell_Wheel_to_Player) ]
you will need to setup a class in python with member functions to get it to work in that way
maybe there is an easier way that I am not aware of.

User avatar
LiveTurkey
Regular
Posts: 109
Joined: Tue Dec 27, 2016 10:50 pm
Location: Brooklyn
Contact:

Re: Is this the right way to set up screens?

#6 Post by LiveTurkey »

justcolorado wrote:I set variables from buttons on screens it with function calls like this.

Code: Select all

            textbutton "Buy":
                action [ Function(trader.sell_Wheel_to_Player) ]
you will need to setup a class in python with member functions to get it to work in that way
maybe there is an easier way that I am not aware of.
What about this? https://www.renpy.org/doc/html/screen_a ... etVariable

SetVariable(variable, value)
Causes variable to be set to value.

So will this work?

action [SetVariable (speaker, "bethany"), Jump speaker]

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Is this the right way to set up screens?

#7 Post by philat »

SetVariable will work. Actual syntax puts the variable name in quotation marks. (Documentation is confusing on this issue.)

action SetVariable("speaker", "bethany")

User avatar
LiveTurkey
Regular
Posts: 109
Joined: Tue Dec 27, 2016 10:50 pm
Location: Brooklyn
Contact:

Re: Is this the right way to set up screens?

#8 Post by LiveTurkey »

philat wrote:SetVariable will work. Actual syntax puts the variable name in quotation marks. (Documentation is confusing on this issue.)

action SetVariable("speaker", "bethany")
I think that worked. Thank you.

How do I use the variable now?
Can I do Jump (speaker) instead of Jump ("bethany")?

Or what about
show speaker smile instead of show bethany smile ?

Where can I use this variable to replace instances of "bethany" and if anywhere, what is the syntax?

Post Reply

Who is online

Users browsing this forum: Google [Bot]