Warning

This documentation is for an unreleased version of MPF!

This is the developer documentation for MPF 0.51, which is the “dev” (next) release of MPF that is a work-in-progress. Use the “Read the Docs” link in the lower left corner to view the developer docs for the version of MPF you’re using.

Machine Variables in Code

You can use machine variables by calling into the MPF machine.

# read machine variable
print(self.machine.get_machine_var("my_variable"))

# configure variable to persist to disk and expire after 1 day (optional)
# alternatively you can also use "machine_vars" in config to achieve the same
self.machine.configure_machine_var("my_variable", persist=True, expire_secs=86400)

# set a variable
self.machine.set_machine_var("my_variable", 17)