The trough device is special; every game must have one. The system completely handles the device events generated for the ball trough.
The function device_add_live
is called whenever a new ball
is successfully served. The live count of the machine is the
number of balls in play for the purposes of game code (i.e. not counting
missing pinballs or balls locked on the playfield from previous games).
The single_ball_play
event is generated when the live count
is reduced to 1. Multiball modes use
this to stop properly. There is also a ball_count_change
event
invoked on every change of the number of balls in play; some games use
this to update playfield multipliers.
Likewise, device_remove_live
is called whenever a ball drains.
It ultimately is the one that generates the end_ball
event
when all balls have drained.
Live count is not necessarily the actual number of balls in play. If a missing pinball suddenly reappears, the live count is not increased.