Changing appearance of previously-made choices

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
Yako
Newbie
Posts: 2
Joined: Mon Jul 01, 2013 6:02 pm
Projects: Bulletproof Hearts
Contact:

Changing appearance of previously-made choices

#1 Post by Yako »

I am working on an Ace Attorney-style investigation/mystery game. Currently, I'm refining the way questioning other characters works. It's implemented with the default choice menus and that's all great; HOWEVER.

I would like to have it so that, when you're at the menu, choices that have already been explored have a different look to them than choices that have not yet been selected. The "chosen" boolean in the choice screen was close to what I want, but it's a persistent variable and I need it to operate on a per-playthrough level. Is there a way to do this at all?

If you need any code from me, or need clarification on what I'm looking for, please tell me. I'm new to asking questions so I'm not sure how to go about it. Thanks for your time.

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

Re: Changing appearance of previously-made choices

#2 Post by apricotorange »

Put the following somewhere in your project, and the "chosen" boolean will work the way you want:

Code: Select all

init python:
    # Track which choices have been chosen
    chosen_choice_tracker = None

    # Action for menu which tracks the chosen choice.
    class NonPersistentChoice(Action):
        def __init__(self, label, value, location):
            self.label = label
            self.value = value
            self.location = location

        def __call__(self):
            chosen_choice_tracker[(self.location, self.label)] = True
            return self.value

    def menu(items):
        global chosen_choice_tracker
        if not chosen_choice_tracker:
            chosen_choice_tracker = {}
        # Get the name of the current statement
        # (This is not a public API, but I couldn't find an equivalent.)
        location = renpy.game.context().current
        # Build the list of items in the form the screen wants
        item_actions = [ ]
        for (label, value) in items:
            action = NonPersistentChoice(label, value, location)
            item_actions.append((label, action, (location, label) in chosen_choice_tracker))
        # Display the screen
        return renpy.call_screen("choice", items=item_actions)

User avatar
Yako
Newbie
Posts: 2
Joined: Mon Jul 01, 2013 6:02 pm
Projects: Bulletproof Hearts
Contact:

Re: Changing appearance of previously-made choices

#3 Post by Yako »

That is working exactly right. Thank you so much!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]