From db977feb4518d95ee7bab99dd658d375e52632a6 Mon Sep 17 00:00:00 2001 From: Anthony van Winkle Date: Sat, 4 Jan 2025 13:29:39 -0800 Subject: [PATCH] Reverse order of virtual switch add to FIFO --- mpf/platforms/virtual.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mpf/platforms/virtual.py b/mpf/platforms/virtual.py index 67a74031d..e6c83a99d 100644 --- a/mpf/platforms/virtual.py +++ b/mpf/platforms/virtual.py @@ -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