Showing a screen or another one after labels or 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
Adrian_DVL
Regular
Posts: 141
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Showing a screen or another one after labels or screens

#1 Post by Adrian_DVL »

Say I'm developing a sandbox-like game in which there are two different maps. I've made these two maps as two different screens, each one with its hotspots and links to labels.

Then I have a loop label that repeats itself during the game to show the map whenever an event (label) is finished or a menu (another screen) is closed, by calling the screen, just like this:

Code: Select all

label showmap:
	if (renpy.music.is_playing('music')):
        	pass
        else:
                play music "sfx/map.mp3" loop
        call screen map1
The screen called by that label is the first map. The thing is that my game was intended to have just one map at first, but now I made a second one.

So my problem is that I literally don't know how I can call (or show, I guess I could make do with that) one map or the other after a certain event or after closing menus (which are also screens). I've tried different functions as well as the typical statements with no luck.

So I made another label to call the second map from there, so that I can jump to one label or another after the different events and problem solved. But I still have the same problem with the menus and some hotspots that are commom to both maps: I don't know how to call one map or another (or jump to one label or another) depending on which one was running before the menu or the hotspot was called, or, in other words, I don't know how to jump to the label that was in charge before a new label was called.

I don't know if I made myself clear, but I hope someone can help me with this!

User avatar
SONTSE
Regular
Posts: 96
Joined: Sun Nov 24, 2013 10:49 pm
Completed: 11 VN's so far
Discord: jkx0282_10798
Contact:

Re: Showing a screen or another one after labels or screens

#2 Post by SONTSE »

i think you should provide exact code you need to fix because usually there are no problem to make a switch between shown statements whatsoever.

Code: Select all

screen map_switch
    if condition:
        use map1
    else:
        use map2

Code: Select all

label mapswitch:
    if condition:
        call screen map1
    else:
        call screen map2
both approaches should work just fine

Adrian_DVL
Regular
Posts: 141
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Re: Showing a screen or another one after labels or screens

#3 Post by Adrian_DVL »

Lena_Borodach wrote: Mon May 27, 2019 1:16 pm i think you should provide exact code you need to fix because usually there are no problem to make a switch between shown statements whatsoever.

Code: Select all

screen map_switch
    if condition:
        use map1
    else:
        use map2

Code: Select all

label mapswitch:
    if condition:
        call screen map1
    else:
        call screen map2
both approaches should work just fine
That would be the correct approach if there were definite conditions to call one screen or another, but it's not the case. For instance, I have a hotspot that leads to a label that is accesible from both of the two maps wherever the state of the game is, and the player can go to that hotspot whenever they want to. When this label is finished, I'd like the game to call the map that was active BEFORE the hotspot was clicked. But I can't predict in which map will the player be at any moment of the game, in order to set conditions to call one screen or another...

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

Re: Showing a screen or another one after labels or screens

#4 Post by philat »

Depends on how it's set up, but an easy way to is set a variable on showing a screen.

Code: Select all

default screen_to_show = "test1"

screen test1():
    on "show" action SetVariable("screen_to_show", "test1")
    # other stuff happens

screen test2():
    on "show" action SetVariable("screen_to_show", "test2")
    # other stuff happens
You can then use the variable to call the screen.

Code: Select all

$ renpy.call_screen(screen_to_show) # this takes the place of call screen map1, basically

Adrian_DVL
Regular
Posts: 141
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Re: Showing a screen or another one after labels or screens

#5 Post by Adrian_DVL »

philat wrote: Tue May 28, 2019 5:21 am Depends on how it's set up, but an easy way to is set a variable on showing a screen.

Code: Select all

default screen_to_show = "test1"

screen test1():
    on "show" action SetVariable("screen_to_show", "test1")
    # other stuff happens

screen test2():
    on "show" action SetVariable("screen_to_show", "test2")
    # other stuff happens
You can then use the variable to call the screen.

Code: Select all

$ renpy.call_screen(screen_to_show) # this takes the place of call screen map1, basically
I'm messing around with this and it definitely is helping me! From how I have the game set up, I have to recode the screens a lot though. But what I tried so far with the SetVariable action is working. Thank you so much!

Post Reply

Who is online

Users browsing this forum: Andredron