Skip to content

PagedMenu select_callback raises AttributeError #71

@thetredev

Description

@thetredev

This code:

from players.entity import PlayerEntity

player_models = dict()


def menu_callback(menu, index, option):
    """Called by a player selecting an option from the Models menu."""
    # Get a PlayerEntity instance
    player = PlayerEntity(index)

    # Tell what's happened
    player.say('model changed to {0}'.format(option.value.name))

    # Save what has been chosen
    player_models[player.userid] = option.value

    # Is the player alive and on a team?
    if not player.isdead and not player.dead_flag and player.team > 1:

        # If yes, change their model to the one chosen
        player.model = option.value.path


class _Models(dict):

    """Extends dict to map models to Model instances by their basenames."""

    def __init__(self):
        """Called on instantiation."""
        # Call dict's constructor
        super(_Models, self).__init__()

        # Create a PagedMenu instance
        self._menu = PagedMenu(
            select_callback=menu_callback,
            title='{0}: Models'.format(info.name),
            description='Choose a model below.'
        )

        # .........

raises the error as soon as I choose the first option I get when the menu is sent to me.
attrib error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions