missionpinball / mpf

Mission Pinball Framework: Open source software to run a real pinball machine.
http://missionpinball.org
MIT License
214 stars 142 forks source link

Create a bool_event_player/first_match_event_player #848

Open toomanybrians opened 7 years ago

toomanybrians commented 7 years ago

We have a situation in BnD which might be fairly common. We have a shot that has three associated inserts which can be lit independent of each other, but if the shot is made, we only want one of the lit options to be serviced. So instead of stacking these with a queue_event_player, it's almost like we want a bool_event_player (something that creates a ~bool~ relay event from any event and then watches for True/False returns and will only call the next handler if a non-False response comes back?

This config snippet illustrates the problem:

  ball_hold_left_vuk_held_ball{mode.mystery_lit.active}:
    start_mystery
  ball_hold_left_vuk_held_ball{mode.hilo_lit.active and not mode.mystery_lit.active}:
    start_hilo
  ball_hold_left_vuk_held_ball{device.achievement_groups.missions["enabled"] and not mode.mystery_lit.active and not mode.hilo_lit.active}:
    start_mission
  ball_hold_left_vuk_held_ball{not mode.mystery_lit.active and not device.achievement_groups.missions["enabled"] and not mode.hilo_lit.active}:
    release_left_vuk_ball

The complexity here is we have n+1 length entries & quantity of entries, whereas it would be nice to be able to have several different things look for this shot, but only the first (highest) one is actually called.

Dunno if there's an elegant way to add something like this to the configs?

jabdoa2 commented 7 years ago

I think we call those relay_events in MPF. So we should either rename them or call it relay_event_player

jabdoa2 commented 7 years ago

Though about this some more. Definitely makes sense. Just needs a nice name. Something like "first_match_event_player"?