lamps Submodule

Classes for controlling lamp shows.

LampController

class procgame.lamps.LampController(game)

Controller object that encapsulates a LampShow and helps to restore lamp drivers to their prior state.

show

LampShowMode that must be added to the mode queue.

shows

Dictionary of LampShow objects.

LampShow

class procgame.lamps.LampShow(game)

Manages loading and playing a lamp show consisting of several lamps (or other drivers), each of which is a track (LampShowTrack, to be precise).

is_complete()

True if each of the tracks has completed.

load(filename)

Reads lines from the given filename in to create tracks within the lamp show. A lamp show generally consists of several lines of text, one for each driver, spaced so as to show a textual representation of the lamp activity over time.

Lines that start with a ‘#’ are ignored as comments. An example (and very short) lamp show follows:

lamp:Left   | ..      ..
lamp:Center |   ..  ..  ..
lamp:Right  |     ..      ..

See LampShowTrack for a complete description of the track line format.

reset()

Clears out all of the tracks in this lamp show.

restart()

Restart the show from the beginning.

tick()

Instructs the lamp show to advance based on the system clock and update the drivers associated with its tracks.

LampShowMode

class procgame.lamps.LampShowMode(game)

Mode subclass that manages a single LampShow, updating it in the mode_tick() method.

load(filename, repeat=False, callback='None')

Load a new lamp show.

restart()

Restart the lamp show.

LampShowTrack

class procgame.lamps.LampShowTrack(line)

A series of schedules to be applied to a driver over a period of time, usually in concert with other tracks to make up a LampShow.

Tracks are initialized from a string with three parts:

  1. An identifier describing the driver to be manipulated by this track. If the identifier has a lamp: prefix the text following it is interpreted as a lamp name (member of lamps); coil: corresponds to members of coils. If neither of these prefixes is present then the name is assumbed to be a lamp name.
  2. A pipe character (|).
  3. A sequence of characters describing the lighting/activation pattern for the driver. In the simplest case such a string would be a series of dots/periods ('.') and spaces.

For example, a lamp show track describing a lamp (named Bonus5X) that would blink on and off might be:

lamp:Bonus5X | ....    ....    ....    ....

Each character in a track represents 1/32nd of a second. This corresponds to the 32 schedule bits of a Driver.

Special characters may be used in place of dots as shorthand for effects such as fades or simply holding a driver on. This makes constructing and tuning large shows much less time-consuming. Four characters may be used:

[ – open with a “hold on”
] – close with a “hold on”
< – open with a fade-in
> – close with a fade-out

Each open must be balanced with a close, although it need not be of the same type. For example, to fade on a lamp and then keep it on:

lamp:Bonus5X |    <                  ][                 ]

This is translated (by expand_line()) to something similar to this:

lamp:Bonus5X |    .  .  .. .. ... .......................

Or, to pulse it in a fade-in-fade-out pattern:

lamp:Bonus5X |       <                     >

To pulse a flasher rapidly:

coil:Flasher2 |       .      .     .     .    .

These special characters may be mixed with the simpler dots and spaces, but there must always be spaces between the open and close characters. Note that the fade effect is not exactly a fade, but rather turning the driver on and off very rapidly to simulate the lamp getting brighter or darker.

Warning

Care must be used when constructing lamp shows controlling coils. Never hold a coil or flasher active for an extended period of time. Otherwise the game will blow a fuse, burn a coil/flasher, or worse.

current_index

Index into the schedules list.

driver

The Driver correspopnding to this track.

is_complete()

True if this track’s schedules have all been used.

name

Name of this track which corresponds to a driver.

reset()

Clears the contents of this track.

restart()

Restarts this track at the beginning.

schedules

Sequence of 32-bit schedule values.

Functions

procgame.lamps.expand_line(str)

Expands special characters <>[] within str and returns the dots-and-spaces representation. Used by LampShowTrack.

Table Of Contents

Previous topic

highscore Submodule

Next topic

modes Submodule

This Page