Create: Computing AgesBrass Docs
Libraries

link

Create Redstone Link frequencies, without placing a link block.

All computers

Create's Redstone Links carry a redstone signal through the air: a transmitter and a receiver holding the same two items share a frequency, and the receiver outputs what the transmitter gets. The link library puts the computer itself on these frequencies, as if it had all the links it needs built in: link.set transmits, link.get listens. There is no block to place, and every computer has it, the Tube Computer included.

Use it to drive a contraption across the base (a door, a Mechanical Press line, a station signal) or to collect alarms from detectors far away, without a line of dust or a cable.

Brass
-- opens the warehouse doors: a Redstone Link receiver (iron ingot + gold ingot) stands next to them
link.set("minecraft:iron_ingot", "minecraft:gold_ingot", true)

A frequency is two items. Write each one as its item id, the name that F3 + H shows at the bottom of item tooltips: "minecraft:iron_ingot", "create:brass_ingot". Without a namespace, minecraft: is understood: "red_dye" is "minecraft:red_dye". The order matters, as on the block: (iron, gold) and (gold, iron) are two different frequencies. The first item is the first slot of the link, the upper one on a link placed on a wall. When in doubt, wrap the link block as a peripheral and ask it: redstone_link.frequency(). An empty slot is "minecraft:air", written in full.

Range. Create's own range applies: 256 blocks by default (the linkRange setting of Create's server config), measured between the computer and each link. Links in unloaded chunks do not take part.

The computer never hears itself. link.get returns the strongest signal of the other links in range. What the computer transmits is never counted, so a program can transmit and listen on the same frequency without hearing its own voice. Two computers on one frequency do hear each other.

At the end of the tick. As with rs.set, a transmission reaches the other links at the end of the computer's tick, and only the last value set within a tick counts.

Until the reboot. A frequency stays on the air until the program sets it back to 0. The end of a program does not silence it, not even an error or Ctrl+T, and neither does a computer waiting for its rotation. A boot, a reboot, a shutdown and the unloading of the computer's chunk silence every frequency and forget them all.

Functions
link.set(item1, item2, power)Transmits on a frequency, like a Redstone Link transmitter powered with that strength. Every receiver of the frequency within range outputs the strongest signal transmitted on it.
link.get(item1, item2)Reads a frequency, like a Redstone Link receiver: the strongest signal transmitted on it by the other links in range (and other computers), 0 when nobody transmits. The computer's own transmission is never counted.

Transmitting

#

link.set(item1, item2, power)

Transmits on a frequency, like a Redstone Link transmitter powered with that strength. Every receiver of the frequency within range outputs the strongest signal transmitted on it.

Parameters
item1 string
the first item of the frequency, like "minecraft:iron_ingot"
item2 string
the second item of the frequency
power number|boolean
a strength from 0 to 15, or true (15) and false (0)
Brass
link.set("minecraft:iron_ingot", "minecraft:gold_ingot", 15)
link.set("red_dye", "blue_dye", true)   -- "minecraft:" is understood
link.set("red_dye", "blue_dye", false)  -- stop transmitting

As with rs.set, a strength above 15 becomes 15, below 0 becomes 0, and it must be a whole number. The errors you may meet:

messagecause
bad item id 'Iron Ingot'the text is not an item id (capital letters, spaces)
unknown item 'minecraft:iron_ingots'no item has that id
too many link frequencies (max 32)the computer already uses 32 frequencies

The limit counts every frequency used since the computer booted, with link.set, link.get or a Redstone Link block driven as a peripheral (Redstone Link). It goes back to zero at the next reboot.

Doors across the base. The control room opens the warehouse doors, 120 blocks away. Next to the doors, a Redstone Link receiver holds an iron ingot and a gold ingot and powers them:

Brass
local DOORS = {"minecraft:iron_ingot", "minecraft:gold_ingot"}

while true do
  write("doors (open/close): ")
  local answer = read()
  if answer == "open" then
    link.set(DOORS[1], DOORS[2], true)
    print("opening")
  elseif answer == "close" then
    link.set(DOORS[1], DOORS[2], false)
    print("closing")
  end
end

A Mechanical Press line switched from afar. The press line stops when its Clutch is powered. A Redstone Link receiver (iron sheet + clutch) next to the Clutch powers it. Far away, a Comparator reads the input vault of the line and powers a Redstone Link transmitter (iron ingot + comparator). The computer runs the line only while there is iron to press, and wakes up on the link event (see link.get):

Brass
local LEVEL = {"minecraft:iron_ingot", "minecraft:comparator"}
local CLUTCH = {"create:iron_sheet", "create:clutch"}

local function update()
  local level = link.get(LEVEL[1], LEVEL[2])
  -- a powered Clutch disconnects: power it to stop the line
  link.set(CLUTCH[1], CLUTCH[2], level == 0)
  if level == 0 then
    print("input empty: line stopped")
  else
    print("input level " .. level .. ": pressing")
  end
end

update()
while true do
  os.pull_event("link")
  update()
end

See also link.get() rs.set()

Listening

#

link.get(item1, item2)

→ number

Reads a frequency, like a Redstone Link receiver: the strongest signal transmitted on it by the other links in range (and other computers), 0 when nobody transmits. The computer's own transmission is never counted.

Parameters
item1 string
the first item of the frequency
item2 string
the second item of the frequency
Returns
number
the strongest signal the other links in range transmit on it, from 0 to 15
Brass
-- a Daylight Detector on the roof powers a transmitter (glowstone dust + clock)
local light = link.get("minecraft:glowstone_dust", "minecraft:clock")
print("daylight: " .. light .. "/15")

The item ids are checked as for link.set, with the same errors.

**The link event.** The first link.get or link.set on a frequency also starts listening to it. From then on, each time the strength received on it changes, the computer queues a link event with three fields:

fieldvalue
athe first item of the frequency
bthe second item
powerthe new strength received, from 0 to 15

Only the frequencies the program already used send it, so call link.get once on each frequency you want to hear. That first call returns what is already on the air: no event comes for it.

e.a and e.b are spelled the way the program first wrote them: after link.get("red_dye", "blue_dye"), the event says "red_dye", not "minecraft:red_dye". Compare with the same spelling. See also Events.

A wireless alarm network. Around the base, each detector (a pressure plate at the gate, a Sculk Sensor at the mine entrance, a tripwire on the pier) powers a Redstone Link transmitter that holds red dye and the item of its zone. The bells of the town hang on a receiver (red dye + bell). The computer listens to every zone, rings the bells while one of them is on, and names the zones on its screen:

Brass
local ZONES = {
  {name = "north gate", item = "minecraft:oak_door"},
  {name = "mine", item = "minecraft:iron_pickaxe"},
  {name = "harbour", item = "minecraft:oak_boat"},
}

for _, zone in ipairs(ZONES) do
  zone.power = link.get("minecraft:red_dye", zone.item)  -- listens from now on
end

local function refresh()
  local alarms = {}
  for _, zone in ipairs(ZONES) do
    if zone.power > 0 then
      table.insert(alarms, zone.name)
    end
  end
  link.set("minecraft:red_dye", "minecraft:bell", #alarms > 0)
  term.clear()
  term.set_cursor(1, 1)
  if #alarms == 0 then
    print("all quiet")
  else
    print("ALARM: " .. table.concat(alarms, ", "))
  end
end

refresh()
while true do
  local e = os.pull_event("link")
  for _, zone in ipairs(ZONES) do
    if e.a == "minecraft:red_dye" and e.b == zone.item then
      zone.power = e.power
    end
  end
  refresh()
end
Tip

To exchange data between computers rather than a strength from 0 to 15, use net (Minicomputer and newer): messages carry text and tables. Redstone Links shine when the other end is a Create contraption or a plain redstone circuit.

See also link.set() os.pull_event()