Showing bg using call and return

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
BadRos
Regular
Posts: 39
Joined: Fri Dec 28, 2018 11:19 am
Location: Italy
Contact:

Showing bg using call and return

#1 Post by BadRos »

Hello to everyone, im trying to understand the call screen and return, i need it to make a freeroaming in-game without crash or end the game using "ctrl key" or skip.
The game map work's for now, i used the map with jump in city places that are labels, but in the main character house im trying to use the return and i have a lot of troubles.
I start the script from the main character room using "jump userroom"

Code: Select all

label userroom:
    if dtime in [0, 1, 2, 3]:
        scene urbase
    else:
        scene urnight
    show screen exitur
    call screen basehud
    $renpy.pause(hard=True)
    
It works for now, it shows "basehud" and "exitur"
ps. if i press the skip there it breaks the game, it hide all the screens but i will check it another time
I press "exitur" and it shows the right bg of the first floor

Code: Select all

screen exitur:
    imagebutton:
        idle "exitbutton"
        hover "exitbutton"
        xpos 880 ypos 875
        action [Hide( "urbase" ), Jump("firflo")]
        

Code: Select all

label firflo:
    $hideall() #HIDES NON HUD SCREENS
    if dtime in [0, 1, 2, 3]:
        scene firflobase
    else:
        scene firflonight
    call screen firflo
So, now im in the first floor of the house and i have the screens to navigate in the first floor:

Code: Select all


screen firflo:
    imagebutton:
        idle "userroombutton"
        xpos 1750 ypos 125
        action Return("userroom")
    imagebutton:
        idle "basefloorbutton"
        xpos 1750 ypos 875
        action Return("baflo")
    use basehud
Then it comes the problem, when i press the button to return in the "userroom" it doesn't change the bg, it hides all the screens and it returns "_return: u'userroom'"
I didn't really understood for now how the return works, it should do something like the jump? why it doesn't show the screens like "exitur" or "basehud" and the userroom background? can anyone say to me what im doing wrong? Also when im in the "no screen and no bg change" if i press the skip it jumps in another place of house, the label after firflo!

Thanks to everyone and sorry for my bad english! Have a good day!

User avatar
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Re: Showing bg using call and return

#2 Post by kostek00 »

Before showing screen you should set skipping function to false and after closing screen to True:

Code: Select all

label userroom:
    if dtime in [0, 1, 2, 3]:
        scene urbase
    else:
        scene urnight
    $ _skipping = False
    show screen exitur
    call screen basehud
    $renpy.pause(hard=True)
    $ _skipping = True
However I also recommend you to prevent dismissing pause and use of roollback and rollforward functions just for safety.

Code: Select all

$ _dismiss_pause = False
$ _rollback = False

For jumping between screens I'm not 100% sure but instead of using return you might want to use Show and Hide. Return does not returns -1 screen or anything simillar.

Code: Select all

screen firflo:
    imagebutton:
        idle "userroombutton"
        xpos 1750 ypos 125
        action [Show("menu name"), Hide("menu name")]
    imagebutton:
        idle "basefloorbutton"
        xpos 1750 ypos 875
        action [Show("menu name"), Hide("menu name")]
    use basehud
If you want transition between those screens use "transition = transition name":

Code: Select all

action [Show("menu name", transition=Dissolve(0.3)), Hide("menu name")]

BadRos
Regular
Posts: 39
Joined: Fri Dec 28, 2018 11:19 am
Location: Italy
Contact:

Re: Showing bg using call and return

#3 Post by BadRos »

Sorry if i didn't reply in the past days, i had a heavy week.

kostek00 wrote: Wed Apr 17, 2019 11:43 pm Before showing screen you should set skipping function to false and after closing screen to True:

Code: Select all

label userroom:
    if dtime in [0, 1, 2, 3]:
        scene urbase
    else:
        scene urnight
    $ _skipping = False
    show screen exitur
    call screen basehud
    $renpy.pause(hard=True)
    $ _skipping = True
Is this for prevent the skip that brokes the game? I will try it today and see how it works!

kostek00 wrote: Wed Apr 17, 2019 11:43 pm However I also recommend you to prevent dismissing pause and use of roollback and rollforward functions just for safety.

Code: Select all

$ _dismiss_pause = False
$ _rollback = False
With this people can still skip and stop like if the $renpy.pause(hard=True) works? I really what that the player can skip but i don't want that it jumps between the labels in the code without touching the imagebuttons
kostek00 wrote: Wed Apr 17, 2019 11:43 pm For jumping between screens I'm not 100% sure but instead of using return you might want to use Show and Hide. Return does not returns -1 screen or anything simillar.

Code: Select all

screen firflo:
    imagebutton:
        idle "userroombutton"
        xpos 1750 ypos 125
        action [Show("menu name"), Hide("menu name")]
    imagebutton:
        idle "basefloorbutton"
        xpos 1750 ypos 875
        action [Show("menu name"), Hide("menu name")]
    use basehud
If you want transition between those screens use "transition = transition name":

Code: Select all

action [Show("menu name", transition=Dissolve(0.3)), Hide("menu name")]
Now i will try everything, i hope to solve this huge problem, also beacause i liked the idea of using return and call screen but i don't understand why when i return a label it doesn't show the right bg and the imagebuttons!
Thanks for your reply!

Post Reply

Who is online

Users browsing this forum: DewyNebula, Google [Bot]