Menus with sets

If you want a menu where each option can only be used once and once only this can be done simply with menu sets. The set should start out empty, or only containing captions you don't want to show. Each time an option is chosen the caption is automatically added to the set so it is not offered again.

This can be useful when the player is talking to an NPC as it allows each topic to be explored once. As the set starts out empty each time in the code below going back to Gran will allow old topics to be talked about again, which is important if they contain clues as to what the player should do next. Adding new topics is simple no new variables have to be added.


default keyFound = False
default pageFound = False

label talkGran:
    $ renpy.dynamic('done', 'talkSet')
    $ done = False
    $ talkSet = set()
    while not done:
        menu:
            set talkSet
            "{alt}Menu. {/alt}What do you want to say?"
            "Ask about the parchment" if pageFound:
                pc "I found this piece of parchment stuck in one of the drawers
                    in gramp's desk."
                gran "That's nice dear."
                pc "Do you know what these symbols mean?"
                gran "I'm sure I don't. Are they hiero-whatnots?"
            "Ask about the key" if keyFound:
                pc "I found this key under the rug in the study.
                    Do you know what it is for?"
                gran "I've not seen that before dearie. No.
                    Under the rug you say?"
            "Ask how she's doing":
                pc "How are you feeling?"
                gran "Oh, can't complain. Can't complain."
                "She proceeds to detail instead the health challenges of her
                equally old friend Dorothy. Her aches and pains, trips to the
                doctor, and the tumble she took at the garden store."
            "Bye":
                $ done = True
    if len(talkSet) == 1:
        # Only said "Bye"
        gran "Was there something you wanted pet?"
        pc "No, I'm good. I'll let you get on."
    else:
        pc "Bye gran."
        gran "Bye sweetie. Come back anytime."
    return

At the end of this code it checks how many options have been used and recorded in the set. If there's only one in there it will be "Bye" option, meaning the PC didn't actually talk to Gran about anything and the closing dialogue can be adjusted accordingly.