Mission Pinball Framework doesn’t have any native way to use time and dates.
To get around the lack of it I did my own code so I could use time and date for high scores and status screen in game.
It works great and I share the code I wrote on my github at clock_mpf.
clock_mpf runs as it’s own mode. I run it with game_mode: false so it can be run when my machine starts.
Just copy the files or code from GitHub and create a clock folder inside your modes folder where you put the folders/files and then add/activate the mode in your config.yaml (or whatever file you use).
#example of modes: in config.yaml
modes:
- clock #Dont forget to add me!
The GitHub code has some example how to use it in clock.yaml.
Here is how it’s built…
- When event mode_clock_started happens it first sets the time.
- Event mode_clock_started starts a timer that loops and every time it completes with event timer_set_clock_time_complete it writes the time to the machine variable named time_variable.
- Machine variable set_date is written to every time time_variable is saved using the event time_variable_saved.
- You can always trigger set_date or set_clock with your own events.
Just use event_player (or some other player) and set_date or set_clock.
#from clock.yaml
event_player:
time_variable_saved: set_date #Set the date when time_variable is written.
timer_set_clock_time_complete: set_clock #write time to set_clock when timer is complete.
mode_clock_started: set_clock #At start of mode so it doesn't take 10 seconds (timers time) to set clock and date.
set_date and set_clock writes date and time to machine variables named time_variable and date_variable. Use it in any way you want.
#from: clock.yaml
machine_vars:
time_variable:
value_type: str
initial_value: banan
persist: true
date_variable:
value_type: str
initial_value: banan
persist: true
Questions? Make a comment.