Quick update from Ren’Py <7.3 to 7.3 for choice history logging.


Choice history logging

It’s where you see which choice you selected in the Log.

Red text is the choice you selected

Before, we had some sort of hack in one of our code scripts. Ideally, we would want another similar such hack for Ren’Py 7.3+ versions, but due to some difficulties, we have instead added the choice update to the base Ren’Py engine code. Hopefully this is only temporary.

Change the menu function in renpy/exports.py.

def menu(items, set_expr, args=None, kwargs=None, item_arguments=None):
    """
    :undocumented:

    Displays a menu, and returns to the user the value of the selected
    choice. Also handles conditions and the menuset.
    """

    global menu_args
    global menu_kwargs

    args = args or tuple()
    kwargs = kwargs or dict()

    nvl = kwargs.pop("nvl", False)

    if renpy.config.menu_arguments_callback is not None:
        args, kwargs = renpy.config.menu_arguments_callback(*args, **kwargs)

    if renpy.config.old_substitutions:
        def substitute(s):
            return s % tag_quoting_dict
    else:
        def substitute(s):
            return s

    if item_arguments is None:
        item_arguments = [ (tuple(), dict()) ] * len(items)

    # Filter the list of items on the set_expr:
    if set_expr:
        set = renpy.python.py_eval(set_expr)  # @ReservedAssignment

        new_items = [ ]
        new_item_arguments = [ ]

        for i, ia in zip(items, item_arguments):
            if i[0] not in set:
                new_items.append(i)
                new_item_arguments.append(ia)

        items = new_items
        item_arguments = new_item_arguments
    else:
        set = None  # @ReservedAssignment

    # Filter the list of items to only include ones for which the
    # condition is true.

    if renpy.config.menu_actions:

        location=renpy.game.context().current

        new_items = [ ]

        for (label, condition, value), (item_args, item_kwargs) in zip(items, item_arguments):
            label = substitute(label)
            condition = renpy.python.py_eval(condition)

            if (not renpy.config.menu_include_disabled) and (not condition):
                continue

            if value is not None:
                new_items.append((label, renpy.ui.ChoiceReturn(label, value, location, sensitive=condition, args=item_args, kwargs=item_kwargs)))
            else:
                new_items.append((label, None))

    else:

        new_items = [ (substitute(label), value)
                      for label, condition, value in items
                      if renpy.python.py_eval(condition) ]

    # Check to see if there's at least one choice in set of items:
    choices = [ value for label, value in new_items if value is not None ]

    # If not, bail out.
    if not choices:
        return None

    # Show the menu.
    try:
        old_menu_args = menu_args
        old_menu_kwargs = menu_kwargs

        menu_args = args
        menu_kwargs = kwargs

        if nvl:
            rv = renpy.store.nvl_menu(new_items)  # @UndefinedVariable
        else:
            rv = renpy.store.menu(new_items)

    finally:
        menu_args = old_menu_args
        old_menu_kwargs = old_menu_kwargs

    # If we have a set, fill it in with the label of the chosen item.
    if set is not None and rv is not None:
        for label, condition, value in items:
            if value == rv:
                try:
                    set.append(label)
                except AttributeError:
                    set.add(label)

    if rv is not None:
        for label, condition, value in items:
            if value == rv:
                try:
                    """Log a choice-menu choice, which is passed in as item_text.
            Implementation based on add_history() in renpy/character.py."""
                    h = renpy.character.HistoryEntry()
                    h.who = ""
                    h.what = "{color=#B72424}{u}" + label + "{/u}{/color}"
                    h.what_args = []

                    if renpy.game.context().rollback:
                        h.rollback_identifier = renpy.game.log.current.identifier
                    else:
                        h.rollback_identifier = None

                    renpy.store._history_list.append(h)

                    while len(renpy.store._history_list) > renpy.config.history_length:
                        renpy.store._history_list.pop(0)
                    except :
           

Since this triggers in the general menu function, it should log choices to your history in both ADV and NVL menu modes.