Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Conditional Carousel Items #1381

Merged
merged 6 commits into from Jun 10, 2019

Conversation

@avanwinkle
Copy link
Collaborator

commented Jun 7, 2019

This PR extends the Carousel mode's selectable_items: list to support conditional entries. These conditions are evaluated when the mode starts and support both player and machine variable conditions.

CHANGES:

  • Carousel stores the complete list as self._all_items during mode_init and parses the list to create self._items during mode_start. Previously, self._items was created during init.
  • Carousel items are no longer stored as player variables.
    • This logic was designed to allow carousel items to be eliminated on a per-player basis. Conditional logic in the events will support this instead.
    • Player variables were written for carousel items but never modified, so this logic was incomplete and not implemented.

QUESTIONS:

  • Carousel will throw an error on mode start if there are no valid items to select. Perhaps it should fail silently with an event instead?

EXAMPLE: Choosing an attract-mode slide based on the number of players in the last game

mode:
  code: mpf.modes.carousel.code.carousel.Carousel

mode_settings:
  selectable_items:
    - title
    - 1player_score{not machine.player2_score}
    - 2player_score{machine.player2_score and not machine.player3_score}
    - 3player_score{machine.player3_score and not machine.player4_score}
    - 4player_score{machine.player4_score}
  next_item_events: s_flipper_right_active, timer_attract_timer_complete
  previous_item_events: s_flipper_left_active

@avanwinkle avanwinkle changed the title Suuport Conditional Carousel Items Support Conditional Carousel Items Jun 7, 2019

@jabdoa2

This comment has been minimized.

Copy link
Collaborator

commented Jun 7, 2019

QUESTIONS:

Carousel will throw an error on mode start if there are no valid items to select. Perhaps it should fail silently with an event instead?

Maybe an empty_list event or something? Make sense to me.

@avanwinkle

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 7, 2019

Updated behavior: Now an empty list will post (carousel_name)_items_empty and stop the mode (without finishing the start), so game logic can handle that accordingly.

@jabdoa2 jabdoa2 merged commit 90b014a into missionpinball:dev Jun 10, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jabdoa2

This comment has been minimized.

Copy link
Collaborator

commented Jun 10, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.