Skip to content

Counter Logic Blocks

Related Config File Sections:

Related How To Guides

"Counters" are logic blocks that track the number of times a certain event happens towards the progress of a completion goal.

Examples include:

  • Hit a target (or shot) X number of times to advance.
  • Hit pop bumpers 75 times to start a Super Jets mode.
  • Counting the number of combos made
  • Keeping track of a bonus multiplier (maybe you use the shot group lane completion event to count progress towards the bonus multiplier, but you configure the max count to be 6, and then if it's hit again, you award an extra ball).

You can use optional parameters to specify whether multiple occurrences in a very short time window should be grouped together and counted as one hit, the counting interval, and whether this counter counts up or down.

Here's an example of a counter you could use to track progress towards super jets:

##! mode: my_mode
counters:
  super_jets:
    count_events: sw_pop
    events_when_hit: pop_hit
    starting_count: 75
    count_complete_value: 0
    direction: down
    events_when_complete: super_jets_start

And here's the logic block we use for the Addams Family mansion awards to make sure the mansions is initialized only once per game:

##! mode: my_mode
counters:
  initialize_mansion:
    count_events: mode_chair_lit_started
    events_when_complete: initialize_mansion
    count_complete_value: 1
    persist_state: true

Monitorable Properties

For dynamic values and conditional events, the prefix for counters is device.counters.(name).

value

: The count of this counter.

enabled

: Boolean (true/false) which shows whether this counter is enabled.

completed

: True if the block is completed. Otherwise False.

This is an example:

##! mode: my_mode
counters:
  test_counter:
    count_events: count_up
    reset_on_complete: false
    count_complete_value: 3
event_player:
  test_event{device.counters.test_counter.value > 1}: count_above_one
  test_event{device.counters.test_counter.completed}: count_completed
##! test
#! start_game
#! start_mode my_mode
#! mock_event count_above_one
#! mock_event count_completed
#! post test_event
#! assert_event_not_called count_above_one
#! post count_up
#! assert_int_condition 1 device.counters.test_counter.value
#! post test_event
#! assert_event_not_called count_above_one
#! post count_up
#! assert_int_condition 2 device.counters.test_counter.value
#! assert_bool_condition False device.counters.test_counter.completed
#! post test_event
#! assert_event_called count_above_one
#! assert_event_not_called count_completed
#! post count_up
#! assert_int_condition 3 device.counters.test_counter.value
#! assert_bool_condition True device.counters.test_counter.completed
#! post test_event
#! assert_event_called count_completed

Common Issues

We try to answer some common questions regarding logic blocks here. If you question is not answered please ask in the forum.

My block only works once. Why?

This is the default configuration of all logic blocks. To change it you first need to set reset_on_complete to True. As a result you blocks will reset when they reach the final step. However, that will not be enough in most cases because disable_on_complete is True by default. Unless you have some enable logic to re-enable the block later, you probably want to set disable_on_complete to False.

When should I used logic blocks and when should I use shots/show_groups?

There is no definitive answer to this question. Generally, it depends on your usecase. Shots and shot_groups serve a very specific usecase. Basically, they implement a sequences of switch hits which trigger lights along the way. If you want to stay within that specific usecase then go with shots because it will be more convenient. If you plan to extend your mode to use more advanced features then go with logic blocks. For instance if you got conditions in your logic (i.e. on how many balls are locked). Another clear indicator for logic blocks would be if your logic is triggered by other elements such as locks (and not just switches).


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