Create: Computing AgesBrass Docs
Devices

Display Link and nixie tubes

A program writes its own lines into any Display Link of its cable network, and sets the text and colour of a row of Nixie Tubes.

Create's Display Link copies text from a source to a display: a Display Board, a row of Nixie Tubes, a sign, a book on a lectern. A program can use it in two ways:

the display librarythe display_link peripheral
where the link standsagainst the computeragainst the computer, or on a Data Cable of its network
what it showsthe lines the computer offers, the same for every link placed on itthe lines the program wrote into that link, each link its own
how a program writesdisplay.set, display.linea cursor and write, as on a screen

With display, the computer is the source, and every link placed on it reads the same lines. With the display_link peripheral, the text lives in the link itself: one computer fills a dozen boards across the factory, each with its own text, through links placed on its cables.

Brass
local link = peripheral.find("display_link")
link.write("Iron: 1250")

Nixie Tubes have a peripheral of their own too, which sets their text and colour with no Display Link at all: see nixie_tube.set_text() below.

Methods
link.set_cursor(x, y)Moves the cursor: the next write starts there.
link.cursor()Where the cursor is. After a write, it sits right after the text.
link.size()The size of the display the link aims at.
link.write(text)Writes at the cursor, over what is already there, and moves the cursor right after the text.
link.clear_line()Empties the line the cursor is on. The cursor does not move.
link.clear()Empties every line of the link.
link.update()Sends the lines to the display now, instead of at the link's next half-second refresh.
nixie.set_text(text [, color])Writes a text across the whole row of tubes, as a name tag would.
nixie.set_color(color)Changes the colour of the whole row, as a dye used on a tube would.

Setting up

  1. Place the Display Link on a Data Cable of the computer's network (Minicomputer and newer), or against the computer itself, and aim it at its display as usual in Create: right-click the display with the link in hand, then place the link. The display can be up to 64 blocks from the link.
  2. That is all. A link that has no source yet takes "Computer output" by itself at the program's first call. If you had picked another source in the link's screen, pick "Computer output" again.
  3. The program finds it with peripheral.find("display_link"), by its name on the cable (display_link@120,64,-35) or by its side when it touches the computer.

When the display changes. As with any Display Link, the link copies its lines to the display every half second, starting at the line chosen in its screen. display_link.update() sends them at once. While the link receives a redstone signal, it sends nothing (Create's rule).

Where the lines live. The lines are kept in the link: they stay after the program ends, and after a reboot, until a program clears them. Every computer of the network writes into the same lines; the last one to write wins. On a link placed against the computer, lines written this way take the place of the computer's display.set lines, until display_link.clear().

Limits. A link holds 64 lines of 256 characters. What the display shows of them depends on its size: display_link.size() tells.

Writing

#

link.set_cursor(x, y)

Moves the cursor: the next write starts there.

Parameters
x number
the column, from 1
y number
the line, from 1

The cursor starts at column 1, line 1. Each wrapped link has its own: wrapping the same link again (peripheral.wrap or peripheral.find once more) gives a new cursor, back at 1, 1. Wrap it once, before the main loop.

Brass
local link = peripheral.find("display_link")
link.set_cursor(1, 2)
link.write("Line 2")

A number below 1 stops the program with bad argument to 'set_cursor' (the cursor starts at 1, 1); beyond 256 columns or 64 lines, the cursor stays at the edge. Whole numbers only.

See also display_link.cursor() display_link.write()

#

link.cursor()

→ table

Where the cursor is. After a write, it sits right after the text.

Returns
table
{x = column, y = line}, where the next write goes
Brass
local link = peripheral.find("display_link")
link.write("Iron: ")
local c = link.cursor()
print(c.x, c.y)   -- 7 and 1

See also display_link.set_cursor()

#

link.size()

→ table⚙ cost 4

The size of the display the link aims at.

Returns
table
{rows = lines, columns = characters}, what the display can show
displayrowscolumns
Display Board2 per block of heightgrows with its width (17 on a board 4 blocks wide)
Nixie Tubes12 per tube of the row
Sign415
Lectern with a book50 (pages)256

With it, a program adapts its text to the board it finds, or checks the board is big enough:

Brass
local link = peripheral.find("display_link")
local size = link.size()
if size.rows < 4 then
  print("this board shows " .. size.rows .. " lines, 4 are needed")
end

A link aimed at nothing it can write on stops the program with the display link points at nothing it can write on.

#

link.write(text)

Writes at the cursor, over what is already there, and moves the cursor right after the text.

Parameters
text string
the text to write; numbers and other values are written as text

write never goes to the next line: move the cursor with set_cursor for that. When the cursor is past the end of the line, spaces fill the gap. A line stops at 256 characters; the rest is cut.

Writing over old text only replaces the characters it covers: "9" written over "10" leaves "90". Empty the line first with display_link.clear_line(), or pad the text to a fixed width:

Brass
local link = peripheral.find("display_link")
local vault = peripheral.find("inventory")
link.set_cursor(1, 2)
link.write(string.format("Iron %6d", vault.count("minecraft:iron_ingot")))

See also display_link.set_cursor() display_link.clear_line()

#

link.clear_line()

Empties the line the cursor is on. The cursor does not move.

Brass
local link = peripheral.find("display_link")
link.set_cursor(1, 3)
link.clear_line()
link.write("Furnaces: running")

See also display_link.clear() display_link.write()

#

link.clear()

Empties every line of the link.

The cursor does not move: call set_cursor(1, 1) to start again at the top. As with display.clear(), a Display Board goes blank, but a sign only blanks its first line. On a link placed against the computer, the computer's display.set lines show again.

Brass
local link = peripheral.find("display_link")
link.clear()
link.set_cursor(1, 1)
link.write("Closed for the night")

See also display_link.clear_line()

#

link.update()

Sends the lines to the display now, instead of at the link's next half-second refresh.

Call it once the whole text is written, so that the display shows all of it at the same moment. It is applied at the end of the tick, once, however many times it is called in that tick (the rule is explained on Create machines). A link that receives a redstone signal still sends nothing.

Brass
local link = peripheral.find("display_link")
link.set_cursor(1, 1)
link.clear_line()
link.write("Train arriving")
link.update()

See also display_link.write()

Nixie tubes

A row of Nixie Tubes shows two characters per tube. In Create, a tube shows the redstone strength it receives, or the text of a name tag or of a Display Link. The nixie_tube peripheral sets the text and the colour of the whole row directly. Put one tube of the row against the computer or against a Data Cable: the others follow.

Both methods are applied at the end of the tick. The text stays after the program ends, until something else writes on the row: the program again, a name tag, or a Display Link aimed at it. Right-clicking a tube with an empty hand takes the text away, and the row shows its redstone strength again.

#

nixie.set_text(text [, color])

Writes a text across the whole row of tubes, as a name tag would.

Parameters
text string
the text of the row, 2 characters per tube from the first one; numbers are written as text
color string optional
a dye colour for the row, as for set_color

The text starts at the first tube of the row, whichever tube was wrapped. What does not fit is not shown; past 64 characters, it is cut.

Brass
local nixie = peripheral.find("nixie_tube")
nixie.set_text("42", "red")

See also nixie_tube.set_color()

#

nixie.set_color(color)

Changes the colour of the whole row, as a dye used on a tube would.

Parameters
color string
a dye colour: white, orange, magenta, light_blue, yellow, lime, pink, gray, light_gray, cyan, purple, blue, brown, green, red or black

grey and light_grey work too. Any other word stops the program with bad argument #1 to 'set_color' (a dye colour: white, orange, ...).

Brass
local nixie = peripheral.find("nixie_tube")
nixie.set_color("lime")
No signal lights

Create's own ComputerCraft peripheral for Nixie Tubes also has setSignal, which lights coloured signal lamps on the tubes. Create draws those lamps only for a ComputerCraft computer, so that method does not exist here. To show a state in colour, use set_color, or a Traffic Light.

See also nixie_tube.set_text()

Example: a warehouse board

A Data Cable runs along the warehouse. On it: a Create Item Vault, a Display Link aimed at a Display Board 5 blocks wide and 2 high (4 lines of 22 characters), and a row of three Nixie Tubes above the door. Every second, the board lists the stock with a ! in front of what runs low, and the tubes show the iron, red when it is low.

Brass
local vault = peripheral.find("inventory")      -- the only inventory on this cable
local link = peripheral.find("display_link")
local nixie = peripheral.find("nixie_tube")

local ITEMS = {
  {id = "minecraft:iron_ingot", label = "Iron ingots", low = 256},
  {id = "minecraft:copper_ingot", label = "Copper ingots", low = 256},
  {id = "create:brass_ingot", label = "Brass ingots", low = 128},
}

local function row(y, text)
  link.set_cursor(1, y)
  link.clear_line()
  link.write(text)
end

while true do
  row(1, "Warehouse stock")
  for i, item in ipairs(ITEMS) do
    local count = vault.count(item.id)
    local mark = " "
    if count < item.low then
      mark = "!"
    end
    row(i + 1, string.format("%s%-15s%6d", mark, item.label, count))
  end
  link.update()

  local iron = vault.count("minecraft:iron_ingot")
  if iron < 256 then
    nixie.set_text(iron, "red")
  else
    nixie.set_text(iron, "lime")
  end
  sleep(1)
end

row can use link because link is a local of the chunk, not of another function. Three tubes show 6 characters: enough for 999999 ingots.