Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Help with a counter and scoring

30 views
Skip to first unread message

nick taseris

unread,
Jan 20, 2025, 1:57:20 PMJan 20
to MPF Users
I set up a counter  to track spinner spins during a mode and then mode shots are awarded a value that is based on those spins. This is the code I am using. If I have no reset or restart events on the counter the scoring works fine but if I try and have the counter reset each time a mode shot is hit then no matter how many spins the counter counts each shot is just worth the base value of 1,000,000. The counter does reset and then start counting up again when mode shots are hit but for some reason the scoring doesn't go up with it.

What am I doing wrong?

counters:
dog_dale_mode_spinner:
starting_count: 0
start_enabled: true
reset_events:
- right_orbit_dog_dale_lit_hit
- right_ramp_dog_dale_lit_hit
- inline_drop_dog_dale_lit_hit
- left_horseshoe_dog_dale_lit_hit
- left_ramp_dog_dale_lit_hit
- left_orbit_dog_dale_lit_hit
- captive_ball_dog_dale_lit_hit
disable_events: mode_dog_dale_afternoon_stopped
count_events:
- s_center_spinner_active

variable_player:
right_ramp_dog_dale_lit_hit{current_player.shots_on_fire <= 6}:
score: 1000000 + (1000000 * (device.counters.dog_dale_mode_spinner.value * .025))
right_orbit_dog_dale_lit_hit{current_player.shots_on_fire <= 6}:
score: 1000000 + (1000000 * (device.counters.dog_dale_mode_spinner.value * .025))
inline_drop_dog_dale_lit_hit{current_player.shots_on_fire <= 6}:
score: 1000000 + (1000000 * (device.counters.dog_dale_mode_spinner.value * .025))
left_horseshoe_dog_dale_lit_hit{current_player.shots_on_fire <= 6}:
score: 1000000 + (1000000 * (device.counters.dog_dale_mode_spinner.value * .025))
left_ramp_dog_dale_lit_hit{current_player.shots_on_fire <= 6}:
score: 1000000 + (1000000 * (device.counters.dog_dale_mode_spinner.value * .025))
left_orbit_dog_dale_lit_hit{current_player.shots_on_fire <= 6}:
score: 1000000 + (1000000 * (device.counters.dog_dale_mode_spinner.value * .025))
captive_ball_dog_dale_lit_hit{current_player.shots_on_fire <= 6}:
score: 1000000 + (1000000 * (device.counters.dog_dale_mode_spinner.value * .025))
player_score{source=="dog_dale_afternoon"}:

Anthony van Winkle

unread,
Jan 20, 2025, 3:28:31 PMJan 20
to MPF Users
You're using the same events to trigger scoring as you are to reset the counter, so each time a shot is hit the counter resets so the value will always be zero. 

You might consider putting those shots into a shot group, firstly, so you can use the shot group's hit event instead of duplicating the code for each shot. Then use the shot group hit event to trigger the score in variable_player, and also have that hit event post a new event in event_player with a name like "dog_dale_spinner_awarded". Then use that new event to reset the counter, so the order of operations ensures the variable_player will award score before the counter is reset.

Also secret python hack: you can use underscores in numbers to help make them more readable: eg 1_000_000 instead of 1000000. I would avoid ever using decimals in any score-related calculations, because if the value results in anything other than a whole number suddenly the player's score is going to have decimal places and your UI will get real weird. On that note, your score may be a little easier to read formatted like so:

score: 1_000_000 + (device.counters.dog_dale_mode_spinner.value * 25_000)

Hope that helps!

nick taseris

unread,
Jan 20, 2025, 5:43:44 PMJan 20
to MPF Users
... of course lol. 

I spend so much time overthinking how to fix issues that I seem to miss the easiest obvious answer. 

Thank you as always Anthony and thanks for the tip on using underscores for numbers.
Reply all
Reply to author
Forward
0 new messages