Linking screens for custom menu [SOLVED]

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
TellerFarsight
Veteran
Posts: 230
Joined: Sun Jun 04, 2017 8:09 pm
Projects: Vora, Secrets Untold
Location: Toronto, ON
Contact:

Linking screens for custom menu [SOLVED]

#1 Post by TellerFarsight » Sun Jun 03, 2018 10:25 am

So I'd like some clarification on how game menus work. I'm making a menu that is a 3 page booklet, where there are buttons to flip pages. Here's some code I whipped up to do this.

Code: Select all

screen page1():
    add "gui/page1.png"
    textbutton "Next Page" action ShowMenu("page2") ypos 650 xpos 1100
screen page2():
    add "gui/page2.png"
    textbutton "Previous Page" action ShowMenu("page1") ypos 650 xpos 100
    textbutton "Next Page" action ShowMenu("page3") ypos 650 xpos 1100
screen playbill_page3():
    add "gui/page2.png"
    textbutton "Previous Page" action ShowMenu("page2") ypos 650 xpos 100
My question is this:
If I call page2, I am then given the option to flip to page1 or page3 (I know it works because the textbuttons highlight), but once I do, it flips to the said page and is then stuck; the button to flip back then becomes inactive. Why does this happen, and how do I fix it? This isn't a problem for the default using the navigation menu, so I know what I'm asking for is possible, but I'm very confused about it.
Last edited by TellerFarsight on Tue Jun 05, 2018 10:49 pm, edited 1 time in total.
Current Project: Vora
Also Check Out: Devil Survivor [Reverse-Engineered]

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Linking screens for custom menu

#2 Post by kivik » Sun Jun 03, 2018 10:39 am

How weird. Just a random idea:

Can you add tag menu in all the screens and see if that works?

Also your page3 screen is called playbill_page3() instead of page3 - but I'm guessing it's a modified version of your coded for our reference and you missed deleting the playbill part?

User avatar
TellerFarsight
Veteran
Posts: 230
Joined: Sun Jun 04, 2017 8:09 pm
Projects: Vora, Secrets Untold
Location: Toronto, ON
Contact:

Re: Linking screens for custom menu

#3 Post by TellerFarsight » Sun Jun 03, 2018 10:48 am

Alright so here's what happened. I had *tag menu* in the code before posting this but that didn't change anything, but I think I got mixed up and didn't re-run the program after saving the new code. Anyway, it works now.
Current Project: Vora
Also Check Out: Devil Survivor [Reverse-Engineered]

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Linking screens for custom menu

#4 Post by kivik » Sun Jun 03, 2018 2:28 pm

Ah, that's when the Developer Tools are quite handy. If you do Shift-R to switch your game to autoreload mode, your game will reload automatically during script changes and image file changes.

I use that extensively when I test my game!

User avatar
TellerFarsight
Veteran
Posts: 230
Joined: Sun Jun 04, 2017 8:09 pm
Projects: Vora, Secrets Untold
Location: Toronto, ON
Contact:

Re: Linking screens for custom menu

#5 Post by TellerFarsight » Sun Jun 03, 2018 10:42 pm

Yeah I've been using that for a long time too, but the test build for my game is, for now, coded in such a way that when it autoreloads certain variable values get lost and the whole thing crashes, so often I just quit out and relaunch.
Current Project: Vora
Also Check Out: Devil Survivor [Reverse-Engineered]

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Linking screens for custom menu

#6 Post by kivik » Mon Jun 04, 2018 8:45 am

Are you using default to declare all your variables?

Have a read of these two links:
https://www.renpy.org/doc/html/python.h ... -statement
https://www.renpy.org/doc/html/save_loa ... t-is-saved

Long story short - use default for all variables that will change during gameplay (and thus needs saving) and only define variables that should never change during the course of the game.

Autoreload works by saving the game first then loading it when code is reloaded, so if it crashes during autoreload, chances are good it'll crash when players save and load the game. (speaking from experience here)

User avatar
TellerFarsight
Veteran
Posts: 230
Joined: Sun Jun 04, 2017 8:09 pm
Projects: Vora, Secrets Untold
Location: Toronto, ON
Contact:

Re: Linking screens for custom menu

#7 Post by TellerFarsight » Mon Jun 04, 2018 11:57 am

Yeah, trooper6 beat that lesson into me last year, I just hadn't gotten around to it. It never came up as a problem for this project until I started working with screens, and only then it crashes if I'm working with screens, I autoreload it to alter the screen, and then exit the screen to go back to the main game again and then quit out anyway. I'll fix it when I get home today, thanks for the reminder.
Current Project: Vora
Also Check Out: Devil Survivor [Reverse-Engineered]

Post Reply

Who is online

Users browsing this forum: Google [Bot]