How to add "Main" to quick 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
10kNing
Regular
Posts: 51
Joined: Fri Apr 29, 2011 9:37 pm
Projects: Revenance (RPG), Mad-Love (GxB, on hold)
Location: NYC
Contact:

How to add "Main" to quick menu? (Solved!)

#1 Post by 10kNing »

Sorry for the silly question, really bad at screen language! I was trying to add an option to jump back to the Main Menu in the quick menu thing:

Code: Select all

screen quick_menu:
    # Add an in-game quick menu.
    hbox:
        style_group "quick"
        xalign 0
        yalign 1.0
        textbutton _("Q.Save") action QuickSave()
        textbutton _("Q.Load") action QuickLoad()
    hbox:
        style_group "quick2"
        xalign .5
        yalign 1.0
        textbutton _("Save") action ShowMenu('save')
        textbutton _("Load") action ShowMenu('load')
        textbutton _("Skip") action Skip()
        textbutton _("Auto") action Preference("auto-forward", "toggle")
    hbox:
        style_group "quick"
        xalign 1.0
        yalign 1.0
        textbutton _("Main") action MainMenu()
        textbutton _("Prefs") action ShowMenu('preferences')
and the other buttons worked and I was still able to jump to the title screen using the "Main" button on the navigation menu thing when you right-click, but trying to return to the main menu from the quick menu yielded this error:
I'm sorry, but an uncaught exception occurred.

Compiling ATL code at game/script.rpy:115
NameError: name 'heartbeat' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\execution.py", line 261, in run
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\ast.py", line 632, in execute
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\python.py", line 977, in py_exec_bytecode
File "common/_layout/screen_main_menu.rpym", line 11, in <module>
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\ui.py", line 237, in interact
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 1798, in interact
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 2036, in interact_core
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 246, in visit_all
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 246, in visit_all
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 246, in visit_all
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 246, in visit_all
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 246, in visit_all
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 248, in visit_all
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 2036, in <lambda>
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\screen.py", line 153, in per_interact
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\screen.py", line 253, in update
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 246, in visit_all
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 246, in visit_all
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 246, in visit_all
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\display\core.py", line 243, in visit_all
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\atl.py", line 392, in visit
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\atl.py", line 326, in compile
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\atl.py", line 470, in compile
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\atl.py", line 727, in compile
File "C:\Users\Marcia\Documents\renpy-6.13.8\renpy\atl.py", line 184, in eval
File "<string>", line 1, in <module>
NameError: name 'heartbeat' is not defined

Windows-post2008Server-6.1.7601-SP1
Ren'Py 6.13.8.1675
It's referring to this:

Code: Select all

    image heart:
        "heart/heart1.png"
        pause ((25 - heartbeat)/150)
        (etc etc etc.)
which relies on a variable that changes depending on what actions so-and-so etc etc.
There's probably an obvious answer to this that I can't see right now... I don't understand screen language very well so I just try to imitate what's already there. How can I make the "Main" option in the quick menu go to the main menu? Thank you!
Edit: Thanks very much~!
Last edited by 10kNing on Mon Jun 25, 2012 8:22 am, edited 1 time in total.

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: How to add "Main" to quick menu?

#2 Post by apricotorange »

Try adding "$ heartbeat=0" to your init code.

Explanation: when the user returns to the main menu, all the variables are immediately reset; however, if you're transitioning directly from your script to the main menu, the displayables don't go away immediately because they're still visible during the transition. Therefore, you have to be careful if you're referring to a game variable from a transform.

An alternative solution would be to use a transform with a parameter instead of referring to the variable directly from the transform; see http://www.renpy.org/doc/html/atl.html .

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], trailsiderice