Create: Computing AgesBrass Docs
Devices

Redstone Link

Create's wireless redstone, driven through the frequency set in a link block: no item ids to type.

Create's Redstone Link sends redstone without wires: a transmitter and the receivers that hold the same two items in their slots share a frequency, up to 256 blocks apart. A computer can already transmit and listen on any frequency with the link library, by typing the item ids. Put a Redstone Link against the computer and it does the same on the frequency set in that link: change the items in the slots by hand, and the program follows, without editing a line.

Brass
local rl = peripheral.wrap("top")
rl.set(true)       -- every receiver of this frequency lights up
print(rl.get())    -- the strongest signal the other transmitters send
Methods
rl.get()The redstone strength that the other transmitters of this frequency send, the strongest of them.
rl.set(power)Transmits on the link's frequency, as the computer.
rl.frequency()The frequency of the link: the ids of the two items in its slots, like "minecraft:iron_ingot". An empty slot reads "minecraft:air".
rl.is_receiver()Whether the link block is set as a receiver.

Setting up

Placing it. Put the link against any face of the computer, or against a Data Cable of the computer's network (from the Minicomputer on; it is then named like redstone_link@120,64,-35). peripheral.find("redstone_link") takes the first one. Set its frequency as usual in Create: an item in each of its two slots. Sneak + right-click switches it between transmitter and receiver.

The computer is the radio, the link only holds the frequency. rl.set and rl.get are exactly link.set and link.get on the link's two items: the computer itself transmits and listens on that frequency, from its own position. So:

  • rl.set(15) powers every receiver of that frequency within range of the computer, and also the link against the computer if it is a receiver;
  • rl.get() reads the strongest signal of the transmitters of that frequency in range, the link against the computer included when it is a transmitter powered by redstone (a lever on it, for example). The computer never hears its own transmission.

Read again on every call. Each method looks at the items in the slots at the moment you call it. Swap the items while the program runs, and the next rl.set transmits on the new frequency.

**Shared with the link library.** The frequencies a program uses through Redstone Links and through link.get / link.set are the same table: a frequency used both ways is one and the same channel, and a computer holds at most 32 of them (too many link frequencies (max 32)). Once a frequency has been used, every change of what it receives queues a link event (e.a, e.b, e.power). What a computer transmits stops when it reboots or shuts down. The range is Create's link range, 256 blocks unless the server changed it. See link for the details.

Signal

#

rl.get()

→ number

The redstone strength that the other transmitters of this frequency send, the strongest of them.

Returns
number
the strongest signal received on the link's frequency, 0 to 15
Brass
local rl = peripheral.wrap("top")
if rl.get() > 0 then
  print("the gate lever is on")
end

The first call also starts listening: from then on, a change of the received strength queues a link event, so the program can sleep instead of asking again and again (see the examples below).

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

#

rl.set(power)

Transmits on the link's frequency, as the computer.

Parameters
power number|boolean
a strength from 0 to 15, or true (15) and false (0)
Brass
local rl = peripheral.wrap("top")
rl.set(15)
rl.set(false)  -- off
rl.set(9)      -- 9 shows green on a Traffic Light next to a receiver

Strengths above 15 count as 15, below 0 as 0. A number with decimals stops the program with bad argument #1 to 'set' (number has no integer representation): round it with math.floor first. The new strength reaches the world at the end of the program's tick, and only the last value of that tick counts, so a loop that switches it thousands of times does not flood the world with updates. The transmission lasts after the program ends, even after an error or Ctrl+T, until the computer reboots or shuts down (its chunk unloading shuts it down too).

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

#

rl.frequency()

→ table

The frequency of the link: the ids of the two items in its slots, like "minecraft:iron_ingot". An empty slot reads "minecraft:air".

Returns
table
{a = id, b = id}, the item ids in the link's two slots

a and b come in the order link.get and link.set take them, so link.get(f.a, f.b) reads the same as rl.get():

Brass
local rl = peripheral.wrap("top")
local f = rl.frequency()
print("frequency: " .. f.a .. " + " .. f.b)

When the block is not a Redstone Link any more (broken, replaced), frequency, get and set stop the program with redstone link not ready, and is_receiver returns false.

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

#

rl.is_receiver()

→ boolean

Whether the link block is set as a receiver.

Returns
boolean
true when the link is in receiver mode, false for a transmitter

It does not change what the computer can do (it both transmits and listens), but it tells what the link block itself does with redstone: a receiver outputs what the frequency carries, a transmitter sends the redstone it gets.

Brass
local rl = peripheral.wrap("top")
if rl.is_receiver() then
  print("receiver: shows " .. rl.get())
else
  print("transmitter")
end

Examples

A wireless alarm for the vault

The link on top of the computer holds the frequency of a lamp across the base (a receiver with the same two items next to it). When the Create Item Vault on the right has room for fewer than 10 stacks, the lamp lights up.

Brass
local rl = peripheral.wrap("top")
local vault = peripheral.wrap("right")
while true do
  local room = vault.size() * 64 - vault.count()  -- for items that stack to 64
  rl.set(room < 640)
  sleep(5)
end

To move the alarm to another lamp, change the items in the link: the program needs no change.

A remote lever, without polling

A lever on a transmitter far away, with the same items as the link against the computer. The program wakes up only when the lever moves, and copies it to the bottom output (a door, a Create clutch or gearshift...).

Brass
local rl = peripheral.wrap("top")
rs.set("bottom", rl.get())  -- the state right now, and listening starts
while true do
  local e = os.pull_event("link")
  local f = rl.frequency()
  if e.a == f.a and e.b == f.b then
    rs.set("bottom", e.power)
  end
end

The check on e.a and e.b keeps the program right if someone changes the link's items: events of the old frequency are ignored.

A survey of the Redstone Links on the computer's cable: their frequency, their mode, and what they receive.

Brass
for _, name in ipairs(peripheral.list("redstone_link")) do
  local rl = peripheral.wrap(name)
  local f = rl.frequency()
  local mode = "transmitter"
  if rl.is_receiver() then
    mode = "receiver"
  end
  print(f.a .. " + " .. f.b .. " (" .. mode .. "): " .. rl.get())
end

Each different frequency counts towards the 32 a computer can use.