Machine Variables
MPF uses the concept of machine variables to track dynamically-created variables that apply on a machine-wide basis. Machine variables are similar in concept to player variables, except machine variables are machine-wide instead of per-player. Examples of things that are stored in machine variables include:
- The number of credits on the machine (if you're using the credits mode and not set to free play)
- The scores of the last game played (which are typically shown in the attract mode display loop)
- The names and scores of the high scores (which are also shown in the attract mode display loop and in the "status" screen when a player holds a flipper button in during a game).
Machine variables can be set to persist
, meaning they are saved to
disk and available to MPF the next time it boots up. (For example, if
you first turn on a pinball machine, it will still show the scores of
the last game played in the attract mode.) These machine variables are
stored in the <your_machine_folder>/data/machine_vars.yaml
file.
Machine variables that are saved to disk can optionally be written with
an expiration time which means they're cleared out if MPF boots after
the time has passed. (For example, the number of credits on the machine
might only persist for a few hours.)
Like player variables, you can use machine variables in your config files, particularly in text display widgets, to show things on your display.
If you want to use a machine variable in a slide player you can access
it similarly to normal variables, you need to use the syntax
(machine|my_var_name)
where my_var_name
obviously has to be replaced
with your variable name. If you want to access the machine variable in a player, e.g. segment player you need to use this syntax
{machine.my_var_name}
. In other words, when using the the first notation with the pipe symbol you access the value of the variable
as a string, in the latter case using the dot notation you access the value itself.
Video about player and machine variables:
You can create your own machine variables in your configs. There are also several machine variables that are automatically created. Here's a list of the machine variables that are "built in" and available for use in your configs:
- credit_units
- credits_denominator
- credits_numerator
- credits_string
- credits_value
- credits_whole_num
- fast(x)_firmware](fast_x_firmware)
- fast(x)_model](fast_x_model)
- (high_score_category)(position)_label
- (high_score_category)(position)_name
- (high_score_category)(position)_value
- (high_score_category)(position)(variable_type)(variable)
- lisy_api_version
- lisy_hardware
- lisy_version
- mc_extended_version
- mc_version
- mpf_extended_version
- mpf_version
- p_roc_hardware_version
- p_roc_revision
- p_roc_version
- pkone_firmware
- pkone_hardware
- platform
- platform_machine
- platform_release
- platform_system
- platform_version
- player(x)_score
- python_version
Related Events
Something missing or wrong? You can fix it!
This website is edited by people like you! Is something wrong or missing? Is something out of date, or can you explain it better?
Please help us! You can fix it yourself and be an official "open source" contributor!
It's easy! See our Beginner's guide to editing the docs.
Page navigation via the keyboard: < >
You can navigate this site via the keyboard. There are two modes:
General navigation, when search is not focused:
- F , S , / : open search dialog
- P , , : go to previous page
- N , . : go to next page
While using the search function:
- Down , Up : select next / previous result
- Esc , Tab : close search
- Enter : go to highlighted page in the results