Different music on ball 2

43 views
Skip to first unread message

Anthony Bates

unread,
Nov 7, 2025, 1:13:34 AMNov 7
to MPF Users
I am getting things running on my game but ran into a snag. My attract mode and base mode seem to be working just fine but I really want to have a different music track play at the start of ball 2. It will still be the same base mode as ball one, just a different music track. No matter what I try, I can only get the ball one music to stop on ball 2 but I can't get the ball 2 music to play. 

My base mode might look like a bit of dog's breakfast now after making so many adjustments but here it is. If anyone has any advice on how to get a different song to play at the start of ball 2, I would really appreciate it. Thanks. 
#config_version=6

mode:
  start_events: ball_starting, mode_escape_graveyard_stopped
  stop_events: mode_escape_graveyard_started, game_ended
  priority: 50

# -----------------------------
# SCORING
# -----------------------------
variable_player:
  s_left_upper_bumper_active:   { score: 10 }
  s_left_lower_bumper_active:   { score: 10 }
  s_left_sling_active:          { score: 10 }
  s_right_sling_active:         { score: 10 }

  s_right_skill_lane_active:    { score: 500 }
  s_left_skill_lane_active:     { score: 500 }
  s_middle_skill_lane_active:   { score: 500 }
  s_rollover_middle_active:     { score: 500 }
  s_rollover_upper_active:      { score: 500 }

  s_saucer_active:              { score: 0 }

  s_spinner_active:             { score: 100 }
  s_left_bank_target_left_active:    { score: 100 }
  s_left_bank_target_right_active:   { score: 100 }
  s_left_bank_target_middle_active:  { score: 100 }
  s_right_bank_target_left_active:   { score: 100 }
  s_right_bank_target_right_active:  { score: 100 }
  s_right_bank_target_middle_active: { score: 100 }
  s_right_inlane_active:             { score: 100 }
  s_left_inlane_active:              { score: 100 }
  s_left_outlane_active:             { score: 100 }
  s_left_rollover_active:            { score: 100 }
  s_right_outlane_active:            { score: 100 }
  s_right_rollover_active:           { score: 100 }
  s_pop_bumper_left_active:          { score: 100 }
  s_pop_bumper_right_active:         { score: 100 }
  s_pop_bumper_bottom_active:        { score: 100 }

# -----------------------------
# EVENTS
# -----------------------------
event_player:
  # fire these as soon as base has started (which happens on ball_started)
  mode_base_started:
    stop_mode_attract: {}
    mode_attract_will_stop: {}
    godot_attract_off: {}
    godot_play_base: {}
    "start_subsequent_loop{current_player.ball>1}": {}

  ball_started{current_player.ball==1}:
    start_firstball_intro: {}

  ball_started{current_player.ball>1}:
    start_subsequent_loop: {}

  mode_base_will_stop:
    godot_stop_base: {}
  mode_escape_graveyard_started:
    godot_stop_base: {}
  game_ended:
    godot_stop_base: {}

  sh_escape_graveyard_start_hit:
    start_mode_escape_graveyard: {}

counters:
  eg_pop_counter:
    count_events:
      - s_left_pop_bumper_active
      - s_middle_pop_bumper_active
      - s_right_pop_bumper_active
    count_complete_value: 3
    reset_on_complete: true
    reset_events: ball_started
    events_when_complete: eg_lit

shots:
  # Saucer starts the mode, but only while lit
  sh_escape_graveyard_start:
    switch: s_saucer
    enable_events: eg_lit
    disable_events: mode_escape_graveyard_started, ball_will_end

slides:
  base_blank:
    - type: rectangle
      width: 100%
      height: 100%
      color: black

slide_player:
  # when base starts, show the black slide (it will sit on top of attract)
  mode_base_started:
    base:
      action: play
      priority: 110
  mode_base_will_stop:
    base_blank: { action: remove }

  start_subsequent_loop:
    base_blank:
      action: play
      priority: 120

show_player:
  mode_base_started:
    attract_wave:  { action: stop }
    attract_pulse: { action: stop }

light_player:
  eg_lit:
    l_left_bank_lower: on       # choose any "start is lit" lamp you like
  mode_escape_graveyard_started:
    l_left_bank_lower: off
  ball_will_end:
    l_left_bank_lower: off

# -----------------------------
# SOUND
# -----------------------------
sound_player:
  start_firstball_intro:
    firstballintro:
      action: play
      loops: 0
      priority: 100
      volume: 0.7

  start_subsequent_loop:
    firstballintro:
      action: stop
      fade_out: 1s
    subsequentball:
      action: play
      bus: music2
      loops: -1
      priority: 100
      volume: 0.7

  mode_base_will_stop:
    firstballintro: { action: stop }
    subsequentball: { action: stop }

  ball_will_end:
    firstballintro: { action: stop }
    subsequentball: { action: stop }

  play_skilllane_quote_1:
    herehecomesnowimgettingoutofhere: { action: play, priority: 50, volume: 0.9 }
  play_skilllane_quote_2:
    heyyourestillafraid:              { action: play, priority: 50, volume: 0.9 }
  play_skilllane_quote_3:
    theyrecomingforyou:               { action: play, priority: 50, volume: 0.9 }
  play_skilllane_quote_4:
    looktherecomesoneofthemnow:       { action: play, priority: 50, volume: 0.9 }
  play_skilllane_quote_5:
    theyrecomingforyoubarbra:         { action: play, priority: 50, volume: 0.9 }
  play_skilllane_quote_6:
    theyrecomingtogetyoubarbra:       { action: play, priority: 50, volume: 0.9 }

# -----------------------------
# RANDOM QUOTES
# -----------------------------
random_event_player:
  s_right_skill_lane_active:
    events:
      - play_skilllane_quote_1
      - play_skilllane_quote_2
      - play_skilllane_quote_3
      - play_skilllane_quote_4
      - play_skilllane_quote_5
      - play_skilllane_quote_6

  s_left_skill_lane_active:
    events:
      - play_skilllane_quote_1
      - play_skilllane_quote_2
      - play_skilllane_quote_3
      - play_skilllane_quote_4
      - play_skilllane_quote_5
      - play_skilllane_quote_6

  s_middle_skill_lane_active:
    events:
      - play_skilllane_quote_1
      - play_skilllane_quote_2
      - play_skilllane_quote_3
      - play_skilllane_quote_4
      - play_skilllane_quote_5
      - play_skilllane_quote_6

zohanscollectibles

unread,
Nov 7, 2025, 1:18:31 AMNov 7
to mpf-...@googlegroups.com
Sound_player: Set a conditional on ball 2 started
Play the sound
--
You received this message because you are subscribed to the Google Groups "MPF Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpf-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mpf-users/b05b6a89-5b6d-4268-bdf9-390b06f9e982n%40googlegroups.com.

Anthony Bates

unread,
Nov 7, 2025, 1:39:38 AMNov 7
to mpf-...@googlegroups.com
Thanks for the rapid response. I actually tried adding a conditional to the sound_player previously. Am I writing it incorrectly or is there something else I need to add to get it to play? The music on the first ball plays fine but then on ball 2 and 3 there is just no music. 
I also tried adding a conditional to my event player and even tried creating an extra show to trigger and get it to play that way, but nothing has been successful. 
sound_player:

  ball_started{current_player.ball==1}:
    firstballintro:
      action: play
      loops: 0
      priority: 100
      volume: 0.7

  ball_started{current_player.ball>1}:
    subsequentball:
      action: play
      loops: -1
      priority: 100
      volume: 0.7

  mode_base_will_stop:
    firstballintro: { action: stop }
    subsequentball: { action: stop }

  ball_will_end:
    firstballintro: { action: stop }
    subsequentball: { action: stop }
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/KnKEn8tQxeo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mpf-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mpf-users/CAPaEFtBNdNHSdkGxBcgMp2Rz5wrrzViVYFkuEEYksX94H8aCNg%40mail.gmail.com.

zohanscollectibles

unread,
Nov 7, 2025, 1:45:36 AMNov 7
to mpf-...@googlegroups.com
Try this 
On the second ball started 

Ball_started{current_player.ball >=2}:

Alex L

unread,
Nov 7, 2025, 1:49:50 AMNov 7
to MPF Users
I would expect the conditional example you showed to work, but perhaps current_player.ball is not quite updated in time, or has some other timing issue. Instead, per the event reference page;
you can use the param ball directly, so "ball_started{ball>=2}". Note that is_extra_ball is also a param there, so you can distinguish between true ball numbers and extras.

Anthony Bates

unread,
Nov 7, 2025, 1:57:30 AMNov 7
to mpf-...@googlegroups.com
Thanks again. I tried changing the phrasing in both ways that you each described and I'm still having the same issue. No music plays at all on ball 2. I've checked the subsequentball.wav file and it plays perfectly fine and it's definitely located in the music folder under sounds. This one has been breaking me. It seems like a very easy thing to sort and I cannot get it to work properly. 

Alex L

unread,
Nov 7, 2025, 2:08:32 AMNov 7
to MPF Users
Huh, that's weird and frustrating! My suspicion would be a playback issue with the sound file or cached version of the sound file --

You could test a couple different things:
1. use a different sound file with the same event+conditional hook
2. make a temporary event_player using that event+conditional definition to see if the binding is executing or not
3. use the problem sound file with an already-working event+conditional hook
4. Maybe loops: -1 is the problem? Doesn't seem like it should be

I'd be interested to hear what the issue turns out to be in the end!

Nixco

unread,
Nov 7, 2025, 4:29:19 AMNov 7
to MPF Users
Hi,
this is the way i did it in 0.80 and it's working well. I want to use random sound for each ball in the future so i use random_event_player. But you can skip this part and directly use sound_player from events in event_player.
song_1, song_2, ..... correspond to song_1.tres, song_2.tres, .... in the sounds folder of my game.

sound_player.yaml

#config_version=6

mode:
    start_events: ball_starting
    priority: 1000

event_player:
    mode_sound_player_started{ball == 1 and not is_extra_ball}: music_first_ball
    mode_sound_player_started{ball == 2 and not is_extra_ball}: music_second_ball
    mode_sound_player_started{ball == 3 and not is_extra_ball}: music_third_ball
    mode_sound_player_started{is_extra_ball}: music_extra_ball
    bonus_start: music_bonus_mode
random_event_player:
    music_first_ball:
        fallback_event: song_1
        events:
            - song_1
    music_second_ball:
        fallback_event: song_2
        events:
            - song_2
    music_third_ball:
        fallback_event: song_3
        events:
            - song_3
    music_extra_ball:
        fallback_event: song_4
        events:
            - song_4
    music_bonus_mode:
        fallback_event: song_5
        events:
            - song_5
sound_player:
    song_1: song_1
    song_2: song_2
    song_3: song_3
    song_4: song_4
    song_5: song_5

Anthony van Winkle

unread,
Nov 7, 2025, 1:28:49 PMNov 7
to MPF Users
I'll just say off the bat that starting and stopping your base mode during a ball is going to cause problems. There's a lot of built-in behavior around base mode and if it stops during a ball, things will get weird. Not saying that's the root cause of your issues, but it certainly complicates things. You should refactor your modes so that base only starts and stops with the ball, and then you should see more consistent behavior from base-related events.

For managing non-wizard behavior I suggest a "global" mode that runs on top of base, as outlined in the Mode Layering guide: https://missionpinball.org/latest/game_design/mode_layering/#mode-relationship-diagram

Anthony Bates

unread,
Nov 7, 2025, 7:13:00 PMNov 7
to mpf-...@googlegroups.com
Amazing. It turns out it was the loops: -1 stopping it from working. I tried testing the same sound file in another trigger that I knew was already working and the file worked just fine. So next I got rid of the loops: -1 and now it's playing correctly on ball 2!

Thank you so much, that was driving me insane. I didn't realise or think that is what the problem would be. 

Also, thank you Anthony. I didn't realise stopping and starting the base mode would cause issues. I've only just started working on another mode that triggers in the saucer and it has been causing MPF to crash when it happens, so maybe that is part of my problem. I'll fix that up and keep working on it. 

Thanks everybody for the help and support, I could not be more thankful. 

Reply all
Reply to author
Forward
0 new messages