Page 1 of 1

Going back to the last used label

Posted: Wed Apr 17, 2019 3:49 pm
by Adabelitoo
I'm my game I have the tipical cellphone where the player can get some info about what he needs to do, his/her stats, his/her achievemnts and outside links. I would like that once you click on the quit button to go back to the previous label used outside the cellphone functions

I now what I am asking is possible because I already saw it in two games but for everything I search before asking here I know is not always so easy, in the worst case I already have a location value setted to each place/room the user can be and I could do a gigantic if location == placeone: jump placeonelabel, but I already have more than 20 places and I'm not done yet adding places so I really don't want to do that gigantic if that I will have to update every single time I add a room.

Not sure what part of the code I should add to make it easier, so here is the basic cellphone, I can always add something else if needed

PS: the f_cellshow is unused at the moment, I had an idea but it didn't worked as planned

Code: Select all

label cellphone():
    if f_cellshow == False:
        if celltab == 1 and f_cellshow == True:
            $ f_cellshow = True
            jump cell_chars
        elif celltab == 2 and f_cellshow == True:
            $ f_cellshow = True
            jump cell_stats
        elif celltab == 3 and f_cellshow == True:
            $ f_cellshow = True
            jump cell_galle
        elif celltab == 4 and f_cellshow == True:
            $ f_cellshow = True
            jump cell_achie
        elif celltab == 5 and f_cellshow == True:
            $ f_cellshow = True
            jump cell_links
        elif celltab == 6 and f_cellshow == True:
            $ f_cellshow = True
            jump cell_devel

label cell_chars():
    $ celltab = 1
    call screen cell_chars

label cell_stats():
    $ celltab = 2
    call screen cell_stats

label cell_galle():
    $ celltab = 3
    call screen cell_galle

label cell_achie():
    $ celltab = 4
    call screen cell_achie

label cell_links():
    $ celltab = 5
    call screen cell_links

label cell_devel():
    $ celltab = 6
    call screen cell_devel

label cell_quit():
    $ f_cellshow = False


Re: Going back to the last used label

Posted: Wed Apr 17, 2019 5:45 pm
by Alex
You can call a label. And if that label has a return statement, the game will return to a line right after this label has been called.
https://www.renpy.org/doc/html/label.ht ... -statement

Re: Going back to the last used label

Posted: Wed Apr 17, 2019 6:53 pm
by Adabelitoo
Alex wrote:
Wed Apr 17, 2019 5:45 pm
You can call a label. And if that label has a return statement, the game will return to a line right after this label has been called.
https://www.renpy.org/doc/html/label.ht ... -statement
Sorry, I'm not completely sure how to aply that to my situation, could you specify?

Re: Going back to the last used label

Posted: Wed Apr 17, 2019 7:26 pm
by plaster
You don't need to handle the tabs with labels. Just do it with screen language.

Assuming you have a way of showing the cellphone, like a button on the quick menu:

Code: Select all

textbutton _("Cell") action Show("cellphone")
... you can handle all the cellphone tab logic on one screen (or a set of screens sharing a tag), like this:

Code: Select all

screen cellphone():
  modal True

  vbox:
    textbutton "X" alt _("Close cell menu") xalign 1.0 action Hide("cellphone")

    hbox:
      # Add buttons to go to your various tabs
      textbutton _("Chars") action SetVariable("celltab", 1)
      textbutton _("Stats") action SetVariable("celltab", 2)
      # ... etc.

    if celltab == 1:
      use cell_chars
    elif celltab == 2:
      use cell_stats
    # etc.
That will show your cellphone screens as a modal, basically on top of your story screen. As soon as you close it, the cellphone is hidden and you're right back to where you were.

That's just one way of setting up the screen, but basically the answer is to do it all within screen statements, rather than labels.

Re: Going back to the last used label

Posted: Wed Apr 17, 2019 9:01 pm
by Adabelitoo
It worked and now I can hide the cellphone, the only problem I have now is that the celltab value was used to remember what screen the user was watching last time and open that tab the next time the user opens the cellphone and now that isn't working anymore and everytime I open the cellphone it always opens the cell_chars tab

Edit: I solved it, the problem was that the unused f_cellshow in the label celphone where I was calling each tab wasn't working because the default value was False and there wasn't anything to set it True and make it work as it should.

Now I have a new problem, after closing it, the buttons of the imagemap behind the cellphone doesn't work, now I have to go to the main map and then go back to that place to make then work