How to use machine variables with segment_display_player?

26 views
Skip to first unread message

kaydeeH

unread,
Oct 12, 2024, 10:56:37 PMOct 12
to MPF Users
Hi again,

Hopefully this one is a touch easier than my usual post... On MPF 0.57.3, MPF-MC 0.57.1. I'm trying a simpler approach to how I've done things in the past and, while in attract, I want to write the last game's scores to the segment_display_player. I've tried all of the following:

segment_display_player:
  timer_display_loop_timer_tick{ticks==0}:
    display1:
      text: "{player1_score:d}"

segment_display_player:
  timer_display_loop_timer_tick{ticks==0}:
    display1:
      text: "{machine|player1_score:d}"

segment_display_player:
  timer_display_loop_timer_tick{ticks==0}:
    display1:
      text(player1_score)

segment_display_player:
  timer_display_loop_timer_tick{ticks==0}:
    display1:
      text(machine|player1_score)

I have confirmed that the variable is available and populated in the machine_vars file by that name, and I also see it listed on the terminal screen under machine variables when the game is running, and I can see the expected value.

When using the () formats, it just writes the literal string "score)" to the displays. When I use the {} formats, it crashes and the log reports the following:

ValueError: Missing variable player1_score

In other places, I do things like the following and it works great:

player_score{player_num==1}:
  display1:
    text: "{players[0].score:d}"

So I'm not sure what I'm missing here. I'm clearly not calling out the variable the way it wants me to.

Thanks in advance,
Kaydee

Ben Tripoli

unread,
Oct 12, 2024, 11:27:04 PMOct 12
to MPF Users
Probably not "players" score since no game is running.

My attract does the same, try this

"{machine.score1_value:d}"

Ben Tripoli

unread,
Oct 12, 2024, 11:40:20 PMOct 12
to MPF Users
Sorry, I replied too quick. I have this which is last player score "{(machine.player1_score):d}"

my reply above is for high score.. sorry about that.

kaydeeH

unread,
Oct 13, 2024, 12:18:03 AMOct 13
to MPF Users
Thank you so much, I'll give this a whirl and report back to close the loop. :)

kaydeeH

unread,
Oct 13, 2024, 12:21:17 AMOct 13
to MPF Users
That worked! Thank you so much.

kaydeeH

unread,
Oct 13, 2024, 12:59:07 AMOct 13
to MPF Users
Follow on question... when there is no last game score for a player (say there wasn't a player 4 in the last game), it writes "0" to the display. what's the best way to say:

if {(machine.player1_score):d} == 0 then "" else {(machine.player1_score):d}

It may be even simpler than that like a boolean operation in the event conditional... I'm sure it's something obvious I'm overlooking, but I'm going cross-eyed at this point, so any tips would be appreciated. Thanks in advance!
Reply all
Reply to author
Forward
0 new messages