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: 3678
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 » Tue Jan 15, 2019 6:58 pm

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

User avatar
DragoonHP
Miko-Class Veteran
Posts: 744
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 » Wed Jan 16, 2019 12:00 am

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

User avatar
trooper6
Lemma-Class Veteran
Posts: 3678
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 » Wed Jan 16, 2019 1:00 am

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

User avatar
DragoonHP
Miko-Class Veteran
Posts: 744
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 » Wed Jan 16, 2019 11:58 am

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: 3678
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 » Wed Jan 16, 2019 7:25 pm

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: 15447
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 » Wed Jan 16, 2019 7:27 pm

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
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
trooper6
Lemma-Class Veteran
Posts: 3678
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 » Wed Jan 16, 2019 9:35 pm

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

User avatar
DragoonHP
Miko-Class Veteran
Posts: 744
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 » Thu Jan 17, 2019 4:37 am

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: Bing [Bot]