ScoringΒΆ

Related Config File Sections
variable_player:

The variable_player is commonly used to score points for the current player when a certain event is posted. This event could be a switch hit (i.e. for s_your_switch use the event s_your_switch_active).

variable_player:
  s_your_switch_active:
    score: 100

Furthermore, you can add or set any other player or machine variable. You can also use dynamic values here.

It is very common to use multipliers in your game for scoring. The simplest way to implement multipliers is to use a player variable to keep the multiplier and multiply it to your scoring entries in variable_player. This is an example for simple scoring with multiplier:

# set initial value for your multiplier player variable (to have it start
# at 1 instead of 0)
player_vars:
  multiplier:
    value_type: int
    initial_value: 1

# in your mode:

variable_player:
  increment_multiplier:
    multiplier: 1
  score_something:
    score: 100 * current_player.multiplier

The multiplier will be tracked per player and carry over to the next ball. At start we set it to 1 using a :doc:player_vars </config/player_vars> entry in config for every player.

You can also reset the multiplier on every ball if you want:

# in your mode:

variable_player:
  # set initial state on mode start of mode "my_mode"
  mode_my_mode_started:
    multiplier:
      int: 1
      action: set
  increment_multiplier:
    multiplier: 1

  score_something:
    score: 100 * current_player.multiplier

Sometimes you want to increase your multipliers after multiple events were posted. For instance, you might want to increase the multiplier after the player completed two shot_groups:

# set initial value for your multiplier player variable (to have it start
# at 1 instead of 0)
player_vars:
  multiplier:
    value_type: int
    initial_value: 1

# in your mode:
accruals:
  bonus_multiplier:
    events:
      - robo_lanes_shots_lit_complete
      - tech_lanes_shots_lit_complete
    events_when_complete: increment_multiplier, light_bonus_2x_led
    start_enabled: True

variable_player:
  increment_multiplier:
    multiplier: 1
  score_something:
    score: 100 * current_player.multiplier

You can also combine two (or more) multipliers (see dynamic values for details about other possible placeholders and math operators):

# set initial value for your multiplier player variables (to have it start
# at 1 instead of 0)
player_vars:
  multiplier:
    value_type: int
    initial_value: 1
  mode_multiplier:
    value_type: int
    initial_value: 1

# in your mode:

variable_player:
  increment_multiplier:
    multiplier: 1
  increment_mode_multiplier:
    mode_multiplier: 1
  score_something:
    score: 100 * current_player.multiplier * current_player.mode_multiplier

You may also just add multipliers instead of multiply them. For instance you could use: score: 100 * (1 + current_player.multiplier + current_player.mode_multiplier) and set initial_value: 0 in player_vars: to have them start at 0.

Another option is to use a counter as multiplier using score: 100 * (device.counters.multiplier_counter.value + 1). See dynamic values for details about possible placeholder.

Sometimes just using math is getting too complicated. For instance, you want to have some special scoring under certain conditions. In this case, it is sometimes better to use conditional events instead of complicated math formulas in a variable_player.

In this example, we enable special scoring if the super_multiball mode is active and the player made more than two loops (just for the sake of the example - you could also move the scoring into super_multiball and remove the first condition):

# set initial value for your multiplier player variables (to have it start
# at 1 instead of 0)
player_vars:
  multiplier:
    value_type: int
    initial_value: 1
  loops_made:
    value_type: int
    initial_value: 0

# in your mode:
variable_player:
  made_loop:
    loops_made: 1
  score_something:
    score: 100 * current_player.multiplier
  score_something{mode.super_extraball.active and current_player.loops_made > 2}:
    score: 1000000

Related How To Guides
High Scores
Scoring Based on Logic Blocks
Scoring based on shots
How to implement solid state game style score queues in MPF