Skip to content

Game Logic

Most (potentially all) of your game logic can be configured in the MPF config files. For classical language programmers new to MPF, an introduction to how the framework handles logical decisions may be helpful. All game logic is tied to event posts. Mostly, this is achieved through config file programming of timers, shots, counters, multiballs, accruals, etc.... These prebuilt modules (listed below) listen for events to be posted then read the state of the hardware and/or perform manipulations on player or device variables. In turn these modules issue their own event posts which drive the behavior or other modules and devices to start and stop modes, control diverts, set bonus multipliers and everything else game related.

A question beginners may have is "How do I tell MPF to perform an action when two or more conditions are met simultaneously?" In an event driven framework this is not the correct way to conseptualize the logic. Again, nothing game related happens without being driven by a posted event. Because events only exist as a descrete moments in time, it does not work to attempt (pseudocode) logic such as IF event1 and event2 then post event3. Nevertheless, MPF provides a flexible and robust mechanism for performing logic on events. This is where Conditional Events come in.

In brief, the the way conditional events work is by telling MPF to process a particular event if and only if additional conditions are met. These conditions (listed inside curly brackets) can relate to player variables (such as score) machine variables (such as credit) or device variables (such as timer ticks or number of balls locked). See for specific examples.

With this flexibility in mind, Here is a list of pre-built game logic modules containing the description, how to guides, links to tutorials, event listings, and configuration


Most of the "How To" guides for these sections still need to be written.

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