Warning

This documentation is for an unreleased version of MPF!

This is the developer documentation for MPF 0.54, 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.variables.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.variables.configure_machine_var("my_variable", persist=True, expire_secs=86400)

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