End a game with a switch combination

22 views
Skip to first unread message

Marc Rechté

unread,
Sep 20, 2025, 11:02:34 AM (5 days ago) Sep 20
to MPF Users
Hello. I did not find a way to force a game to end. In the time being, I did a small fix in modes/game/game.py to use a key tagged "reset" on top of a start request. Shall I push it to the project ?

Philip Dixon

unread,
Sep 20, 2025, 11:19:30 AM (5 days ago) Sep 20
to MPF Users
in python I use this:
    def kill_game(self, **kwargs):
        self.machine.events.post('autolaunch')  # this fires any ball in the shooterlane, I have it set in my ball device to do this.
        self.machine.modes.game.end_game()
        self.machine.ball_controller.collect_balls(target='home, trough')
        self.machine.reset()

Dan - aka BorgDog

unread,
Sep 20, 2025, 12:54:50 PM (5 days ago) Sep 20
to MPF Users
I use this in yaml to end a game. basically posting the event end_game ends the game. it does not automatically plunge a ball in the shooter lane, but I'm sure I could add something to make it do that.

timed_switches:
  game_cancel:
    switch_tags: start
    time: 5 s
    events_when_active: end_game

Dan - aka BorgDog

unread,
Sep 20, 2025, 1:05:32 PM (5 days ago) Sep 20
to MPF Users
end_game is the default event for end_game_event which cna be set in the game: section of your config. I use end_ball as well both referenced here:   https://missionpinball.org/latest/config/game/

Marc Rechté

unread,
Sep 21, 2025, 3:42:11 AM (4 days ago) Sep 21
to mpf-...@googlegroups.com
Thanks. This is what I was initially looking for.

Le 20/09/2025 à 18:54, Dan - aka BorgDog a écrit :
> I use this in yaml to end a game. basically posting the event end_game
> ends the game. it does not automatically plunge a ball in the shooter
> lane, but I'm sure I could add something to make it do that.
>
> timed_switches:
> game_cancel:
> switch_tags: start
> time: 5 s
> events_when_active: end_game
>
> On Saturday, September 20, 2025 at 8:19:30 AM UTC-7 Philip Dixon wrote:
>
> in python I use this:
>     def kill_game(self, **kwargs):
> self.machine.events.post <http://
> self.machine.events.post>('autolaunch')  # this fires any ball in
> the shooterlane, I have it set in my ball device to do this.
>         self.machine.modes.game.end_game()
>         self.machine.ball_controller.collect_balls(target='home,
> trough')
>         self.machine.reset()
>
> On Saturday, September 20, 2025 at 4:02:34 PM UTC+1 mre...@gmail.com
> wrote:
>
> Hello. I did not find a way to force a game to end. In the time
> being, I did a small fix in modes/game/game.py to use a key
> tagged "reset" on top of a start request. Shall I push it to the
> project ?
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "MPF Users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/
> mpf-users/wRshAvnTAYk/unsubscribe <https://groups.google.com/d/topic/
> mpf-users/wRshAvnTAYk/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to mpf-
> users+un...@googlegroups.com <mailto:mpf-
> users+un...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/mpf-
> users/f965d1e5-0331-4f75-8963-feec6b97c63en%40googlegroups.com <https://
> groups.google.com/d/msgid/mpf-users/f965d1e5-0331-4f75-8963-
> feec6b97c63en%40googlegroups.com?utm_medium=email&utm_source=footer>.

Reply all
Reply to author
Forward
0 new messages