Skip to content

Commit

Permalink
Reverse order of virtual switch add to FIFO
Browse files Browse the repository at this point in the history
  • Loading branch information
avanwinkle committed Jan 4, 2025
1 parent d9d9456 commit db977fe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mpf/platforms/virtual.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,18 @@ def _set_ball_device_switch_state(self, ball_device, ball_position, switch_state
# If an explicit switch is designated, deactivate that one.
if ball_position >= 0:
switch = switches[ball_position]
# Otherwise get the last active switch
# Otherwise get the next switch to change state
else:
switches = [s for s in switches if self.machine.switches[s].state != switch_state]
# If none are active, do nothing
if not switches:
return
switch = switches[-1]
# For removing a ball, choose the LAST switch
if not switch_state:
switch = switches[-1]
# For adding a ball, choose the EARLIEST switch
else:
switch = switches[0]
self.machine.switch_controller.process_switch(switch, switch_state)
return switch

Expand Down

0 comments on commit db977fe

Please sign in to comment.