Contains the Player class which represents a player in a pinball game.

class mpf.core.player.Player(machine, player_list)

Base class for a player. One instance of this class is created for each player.

The Game class maintains a “player” attribute which always points to the current player. You can access this via game.player. (Or

This class is responsible for tracking per-player variables. There are several ways they can be used:

player.ball = 0 (sets the player’s ‘ball’ value to 0) print player.ball (prints the value of the player’s ‘ball’ value)

If the value of a variable is requested but that variable doesn’t exist, that variable will automatically be created (and returned) with a value of 0.

Every time a player variable is changed, an MPF is posted with the name “player_<name>”. That event will have three parameters posted along with it:

  • value (the new value)
  • prev_value (the old value before it was updated)
  • change (the change in the value)

For the ‘change’ parameter, it will attempt to subtract the old value from the new value. If that works, it will return the result as the change. If it doesn’t work (like if you’re not storing numbers in this variable), then the change paramter will be True if the new value is different and False if the value didn’t change.

Some examples:

player.score = 0

Event posted: ‘player_score’ with Args: value=0, change=0, prev_value=0

player.score += 500

Event posted: ‘player_score’ with Args: value=500, change=500, prev_value=0

player.score = 1200

Event posted: ‘player_score’ with Args: value=1200, change=700, prev_value=500

monitor_enabled = False

Class attribute which specifies whether any monitors have been registered to track player variable changes.