Create: Computing AgesBrass Docs
Libraries

display

Lines for a Create Display Link pointed at the computer: display boards, nixie tubes, signs.

All computers

Create's Display Link copies information from a source block to a display: a Display Board, a row of Nixie Tubes, a sign, a book on a lectern. A computer is a source too, and the display library chooses the lines it offers. Every computer has it, the Tube Computer included: a station board or a stock counter does not need a screen.

Brass
display.set({"Iron", "1250 ingots"})

Setting up. As with any Create source:

  1. Right-click the display (the target) with the Display Link in hand, then place the link against the computer, on any face. The target can be up to 64 blocks away from the link (Create's displayLinkRange setting).
  2. Right-click the Display Link: its source is "Computer output". Choose the line of the display where the text starts.
  3. In the program, write the lines with display.set or display.line.

When the display changes. The Display Link reads the computer's lines every half second (10 ticks) and copies them to its target, from the line chosen in its settings. A program can call display.set as often as it likes: only the lines present at the next reading show. While the Display Link receives a redstone signal it stops updating (Create's rule for every Display Link), and it updates again as soon as the signal stops.

What each display shows.

displaywhat it shows
Display Boardone line of the computer per line of the board: 2 lines per block of height, a little over 4 characters per block of width (17 on a board 4 blocks wide). The lines of the board below the computer's last line are blanked (down to a line that another Display Link writes). The board only works while it turns.
Nixie Tubesthe first line only, 2 characters per tube of the row
Sign4 lines at most, each cut to the width of the sign
Lectern with a bookone line per page

Every Display Link pointed at the computer gets the same lines. Several links can read one computer (a board on one face, a row of nixie tubes on another), but the nixie tubes always show line 1.

Lifetime. The lines stay until the program changes them, even after it ends. A reboot or a shutdown empties them, and the display goes blank at the next reading.

Functions
display.set(lines)Replaces every line offered to the Display Links.
display.line(n, text)Changes one line and keeps the others.
display.clear()Removes every line: the computer offers nothing to its Display Links any more.

Writing lines

#

display.set(lines)

Replaces every line offered to the Display Links.

Parameters
lines table|string
a list of lines, or one text in which each "\n" starts a new line

It takes a list of lines, or a single text:

Brass
display.set({"Iron", "1250 ingots"})     -- two lines
display.set("Iron\n1250 ingots")          -- the same two lines
display.set({"Speed", 128, "RPM"})        -- numbers are written as text
display.set()                             -- no lines at all, like display.clear()

The limits: 16 lines and 128 characters per line. Longer lines are cut, and the values after the 16th of a list are left out. In a single text, the 16th line keeps all the rest of the text. Each value of a list becomes text the way tostring writes it.

A station departure board. A Display Board 5 blocks wide and 2 high (4 lines of 22 characters) shows the next trains. Times are Minecraft time: os.day_time() counts 1000 ticks per hour, and 0 is 6:00 in the morning. The board is built by a function, so it can be tried with a fixed time:

Brass
local DEPARTURES = {
  {time = 7500, train = "Iron Express", platform = 1},
  {time = 9000, train = "Coal Shuttle", platform = 2},
  {time = 12000, train = "Harbour Line", platform = 1},
}

local function clock(ticks)
  local t = (ticks + 6000) % 24000
  return string.format("%02d:%02d", t // 1000, t % 1000 * 60 // 1000)
end

local function board(now)
  local lines = {"Departures   " .. clock(now)}
  for _, d in ipairs(DEPARTURES) do
    if d.time >= now then
      table.insert(lines, string.format("%s %-13s P%d", clock(d.time), d.train, d.platform))
    end
  end
  return lines
end

for _, line in ipairs(board(7000)) do
  print(line)
end
Screen
Departures   13:00
13:30 Iron Express  P1
15:00 Coal Shuttle  P2
18:00 Harbour Line  P1

On the computer, the last loop becomes the program's main loop, with the real time:

Brass
while true do
  display.set(board(os.day_time()))
  sleep(5)
end

When a train has left, its line disappears and the ones below move up; the board blanks the lines left over.

See also display.line() display.clear()

#

display.line(n, text)

Changes one line and keeps the others.

Parameters
n number
the number of the line, from 1 to 16
text string
the text of that line (numbers and other values are written as text)

Handy when a few values change at different times: the title stays, only the figures move.

Brass
display.set({"Furnace room", "", "Coal left"})
display.line(2, "running")
display.line(4, 512)   -- line 4 did not exist yet: it is added

When n is beyond the last line, the lines in between are added, empty. A number below 1 or above 16 is ignored, with no error. n must be a whole number. Leaving out the text writes the word nil: to blank a line, write display.line(n, "").

A stock counter on nixie tubes. A row of three Nixie Tubes shows 6 characters: enough for the iron of the vault on the left. Nixie tubes show the first line only, so the count goes on line 1:

Brass
local vault = peripheral.wrap("left")
while true do
  display.line(1, vault.count("minecraft:iron_ingot"))
  sleep(2)
end

See inventory.count() for the vault, and Stock alarm and display board for a complete stock alarm.

See also display.set() display.clear()

#

display.clear()

Removes every line: the computer offers nothing to its Display Links any more.

At the next reading, a Display Board and Nixie Tubes go blank. A sign and a lectern only blank the first line (or page) the link writes to, and keep the others: to wipe a whole sign, send it empty lines instead.

Brass
display.clear()                    -- a board goes blank
display.set({"", "", "", ""})      -- a sign goes blank too

A clock on a sign. The time of day on a sign in the town square, refreshed every few seconds (the built-in clock program does the same with a monitor):

Brass
while true do
  local t = (os.day_time() + 6000) % 24000
  local text = string.format("%02d:%02d", t // 1000, t % 1000 * 60 // 1000)
  display.set({"", "Town hall", text, ""})
  sleep(5)
end

A Minecraft hour lasts 50 seconds, so a refresh every 5 seconds keeps the minutes close enough for a town clock.

Tip

A computer with a screen can show more than a Display Link: colours, bars, drawings. Put a CRT Monitor or an LCD Monitor against it (Monitors, Screens and monitors) and draw with term or gfx. The Display Link stays the right choice for Create's own displays, and for computers without a screen nearby.

See also display.set()