menu sets not working anymore

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

menu sets not working anymore

#1 Post by trooper6 »

Hello!

I was just going to test some menu set code that had worked before so I could answer a question in the Q&A section...and the menu set code doesn't work anymore!

The code I'm talking about was demonstrated in this thread
viewtopic.php?p=491503#p491503

Anyone know what happened? Or if that functionality might come back?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: menu sets not working anymore

#2 Post by DragoonHP »

I didn't even know set was a thing!
It looks so awesome

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: menu sets not working anymore

#3 Post by trooper6 »

It was super, super awesome and worked like a dream...but it isn't working anymore and I'm not sure why not.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: menu sets not working anymore

#4 Post by DragoonHP »

So I found out what was causing it to not work.

In renpy/exports.py Line 920, delete the old code block and add this

Code: Select all

    if set_expr is not None and rv is not None:
        for label, value in items:
            if value() == rv:
                try:
                    set.append(label)
                except AttributeError:
                    set.add(label)
Explanation:

* At line 920, old line was if set is not None and rv is not None.
At line 902, set is being assigned the value of the variable you provided in the menu. Chances are, that variable will be empty and so will equal to none. And because at line 920, we need to only check if we provided a variable for set.


* At line 922, old line was value == rv. Value is an instance of ui.ChoiceReturn class while rv is an int (the index of the chosen caption).
And there is no way a class and int will ever be equal.
ui.ChoiceReturn class is programmed to return the index of the chosen caption on call, so we call the class and then compare it's value against rv.

Things to be aware of:

* If your game has a circular menu (that is choosing an option returns you to the menu) the game will crash when the player will have chosen all the options/caption. For those cases, I will advice you to include a Back button which does not participate in set. To circumvent that change line 905 to

Code: Select all

if label not in set or label == "Back"
You can even make it a config variable to customise this caption text. Something like

Code: Select all

config.ignore_menu_set = ["Back", "Exit", "Return"]
Last edited by DragoonHP on Thu Jan 17, 2019 1:36 am, edited 1 time in total.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: menu sets not working anymore

#5 Post by trooper6 »

I suppose my question is, what was the code before when it still worked...and why was that code changed? Can it changed back again without breaking something else?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: menu sets not working anymore

#6 Post by PyTom »

Are you getting an error? I'm not aware of it breaking, but it might have. I've opened a bug at:

https://github.com/renpy/renpy/issues/1688

To track this problem.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: menu sets not working anymore

#7 Post by trooper6 »

No error is thrown, but clicking on a menu option no longer adds it to the set...the functionality of the menu set doesn't work.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: menu sets not working anymore

#8 Post by DragoonHP »

PyTom fixed it in the latest commit. You can either wait for the new release or copy paste the changes from this commit. https://github.com/renpy/renpy/commit/b ... b6a09fa540

Post Reply

Who is online

Users browsing this forum: No registered users