Skip to content

Printing Press Internal Mechanics

Tim Goddard edited this page Jun 10, 2013 · 3 revisions

Implementation of the continuous queue

When printing starts, all material counts and the queue are zeroed. Each time fuel is consumed, the press attempts to produce outputs and load materials.

The queue is, by default, 12 slots long (configurable). Each time fuel is taken, we take items off the end and add a lot of books/pamphlets/security notes to the start. This creates a 12 x energy time minimum run period. Inputs can arrive at any time, and as long as we keep feeding we'll get outputs 12 x energy time after the materials are taken.

First, it produces any outputs. It takes a number off the end of the production queue, and puts that many items in the chest.

To load materials, it loads a single lot of paper and ink (16 paper + 2 ink). This is added to the input buffer. Then it tries to consume other materials - bindings or security materials - until it has enough for all the paper currently held.

Once this is done, it uses the currently held paper and other materials to add items to the queue. As long as it has enough for a single copy, this will be added. We write the number of books we have materials to produce to the start of the production queue, and take those materials out of the input buffer. After 12 fuel has been burned, this will be the front slot of the queue and those items will emerge.

Notes

  • The queue is implemented as a ring buffer because its size is fixed.
Clone this wiki locally