Create: Computing AgesBrass Docs
Devices

Create Aeronautics sensors

Height, tilt, speed, obstacles and heading of a flying ship, read by a computer from the sensors of Create Aeronautics.

Needs Create Aeronautics

Everything on this page exists only when Create Aeronautics is installed (it comes with Create Simulated, which adds these blocks). Without it, there is no such block, and peripheral.find("gimbal_sensor") returns nil.

Create Aeronautics gives its flying ships a set of sensors. On their own they send redstone signals; a computer reads their exact values instead, as numbers it can compute with: the height of the ship, how much it leans, how fast it goes, what is in front of it, where its target is.

Block (in game)peripheral typewhat it reads
Altitude Sensoraltitude_sensorthe height (world Y) and the air pressure
Gimbal Sensorgimbal_sensorhow much the ship leans, in degrees
Velocity Sensorvelocity_sensorthe speed along one axis, in blocks per second
Optical Sensoroptical_sensorthe first block its laser beam hits, and how far
Navigation Tablenavigation_tablethe direction and the distance of a target
Swivel Bearingswivel_bearingthe angle it turns its structure to
Torsion Springtorsion_springits angle and its angle limit
Directional Linked Receiverdirectional_linkhow far off its axis a Redstone Link transmitter is
Modulating Linked Receivermodulating_linkthe distance to a Redstone Link transmitter
Docking Connectordocking_connectorthe name of the ship docked to it
Linked Typewriterlinked_typewriterthe keys a player holds on it
Nameplatename_platethe name of the ship, which it can change

The Hot Air Burner of Aeronautics is a peripheral too: it has its own page, Hot Air Burner, with the Steam Vent. So are its propellers: Propellers. And so are many more blocks of Simulated and Offroad, from the Throttle Lever to the Borehead Bearing: Create Aeronautics blocks.

Reaching a sensor. Like every device, a sensor touching the computer is called by the side it is on ("left", "top"...), and a sensor touching a Data Cable (Minicomputer and newer) gets a network name such as altitude_sensor@12,70,-3. The easiest is to let peripheral.find look for it by type:

Brass
local alt = peripheral.find("altitude_sensor")
local gyro = peripheral.find("gimbal_sensor")
print("height " .. alt.height())
print("tilt X " .. gyro.angle_x() .. ", Z " .. gyro.angle_z())

Every computer can read a sensor placed against one of its faces. A sensor on a ship and a computer on the ground do not touch, so in practice the computer flies with the ship, often a Microcontroller (see Airship altitude hold).

What comes back. Numbers are rounded to 3 decimals (64.5, 0.871). Each call reads the block again, so a value is always fresh, and a wrapped sensor never goes stale. When something is wrong, the call stops the program with an error you can catch with pcall:

errorwhen
altitude sensor removedthe block was broken or replaced since peripheral.wrap (its type, with spaces)
peripheral is not loadedthe chunk of the sensor is not loaded
this version of Create Simulated has no getWorldHeightyour version of Create Simulated lacks that reading (the name at the end is the one missing)
Create Simulated error: ...the sensor itself failed while answering
Note

If you know Simulated's own ComputerCraft peripherals: the readings are the same ones, under this mod's names (height() rather than getHeight()), and the gimbal angles come in degrees, one method per axis.

Methods
sensor.read()Reads all the values of a block in one call, and returns them in a table whose keys are the names of its methods.
alt.height()The height of the sensor in the world, in blocks: the Y coordinate of the centre of the block.
alt.pressure()The air pressure where the sensor is: 1 at sea level, less and less as you climb.
gyro.angle_x()The tilt of the ship around its X axis (the east-west axis), in degrees: the "nose up, nose down" of a ship that flies north or south.
gyro.angle_z()The tilt of the ship around its Z axis (the north-south axis), in degrees: how much it rolls to one side.
speedo.velocity()The speed of the ship along the axis of the sensor, in blocks per second (Aeronautics writes m/s: the same thing).
eye.hit()Whether the beam hits a block within its range.
eye.distance()How far the block is, in blocks, measured from the centre of the sensor to the point where the beam touches the block. nil when the beam hits nothing.
eye.block()The id of the block the beam hits, such as "minecraft:oak_log" or "create:andesite_casing". nil when the beam hits nothing.
eye.range()The longest distance the beam reaches, in blocks: the value box on the sensor. A new sensor starts at the server's maximum, 15 blocks unless the server config optical_sensor_max_range says otherwise.
eye.set_range(blocks)Changes the length of the beam, like turning its value box. The value is kept between 1 and the server's maximum (15 by default), and the function returns nothing: read range() to see what was kept.
nav.angle()The direction of the target, in degrees from 0 to 360, measured flat in the plane of the table. It turns with the ship: when the ship turns, the angle changes.
nav.distance()The distance from the table to the target, in blocks, in a straight line.
bearing.target_angle()The angle the bearing is turning its structure to, in degrees. The structure follows it physically, a little behind.
spring.angle()How far the spring is wound now, in degrees.
spring.limit()The angle limit set on the value box of the spring, in degrees: 90 on a new spring, from 1 to 360.
spring.running()true while the spring moves (its angle changed during the last tick), false when it is at rest.
spring.set_limit(degrees)Changes the angle limit, only while the spring is at rest. When it turns, nothing changes and the function returns false, as in Simulated's own ComputerCraft peripheral: changing the range in the middle of a swing would make it jump.
rx.angle()How far from straight ahead the transmitter is, as the Directional Linked Receiver sees it: 0 when the transmitter is right in front of the receiver's face, 90 when it is level with the face, off to one side.
rx.distance()The distance from the Modulating Linked Receiver to the nearest powered transmitter on its frequency, in blocks, in a straight line from the centre of one block to the centre of the other, with the real positions in the world.
dock.connected_name()The name of the vehicle on the other side of the Docking Connector. Two connectors dock face to face: one on a ship and one on another ship, or on a dock on the ground. A connector on the dock reads the name of the ship that came in.
keys.pressed_keys()The keys a player holds on the Linked Typewriter right now. A player right-clicks the typewriter to use it, and leaves it with Escape. While they use it, the keys bound on the typewriter go to it instead of moving the player: each one sends its Redstone Link frequency, and the computer reads the keys themselves.
plate.name()The name on the Nameplate. On a vehicle that has a name, the plate shows that name, so this is the name of the ship: the one vehicle.name() gives on board and docking_connector.connected_name() gives at the dock. "" when there is no name at all.
plate.set_name(name)Writes a new name on the Nameplate, as a player does in its screen. On a vehicle, it renames the vehicle too: every Nameplate of the ship, vehicle.name() on board and the docking connectors now see the new name. A waxed plate only changes its own name.

Every reading at once

#

sensor.read()

→ table

Reads all the values of a block in one call, and returns them in a table whose keys are the names of its methods.

Returns
table
every reading of the block, by name

Not only the sensors have it: so does every block of Create Aeronautics, Create Simulated and Offroad that a computer reaches, such as the Hot Air Burner, the Steam Vent, the propellers and the blocks of Create Aeronautics blocks. The keys are the names of the methods that only read:

blockkeys of read()
altitude_sensorheight, pressure
gimbal_sensorangle_x, angle_z
velocity_sensorvelocity
optical_sensorhit, distance, block, range
navigation_tableangle, distance
swivel_bearingtarget_angle
torsion_springangle, limit, running
directional_linkangle
modulating_linkdistance
docking_connectorconnected_name
linked_typewriterpressed_keys
name_platename
hot_air_burneroutput, signal, amount, filled, capacity
steam_ventoutput, signal, amount, filled, capacity
propeller_bearingthrust, airflow, active
andesite_propeller, wooden_propellerthrust, airflow, active, reversed
smart_propellerthrust, airflow, active, reversed, tilt

On the blocks of Create Aeronautics blocks, the keys are the names of every method without set_ in its name, apart from assemble and disassemble.

A reading that is nil is simply missing from the table: an Optical Sensor that sees nothing has no distance and no block key.

Brass
local gyro = peripheral.find("gimbal_sensor")
local m = gyro.read()
print("X " .. m.angle_x .. "  Z " .. m.angle_z)

Two good reasons to prefer it in a loop: one call costs less than two or three, and all the values belong together. With separate calls, a long program can be paused by its instruction budget between two of them, and the second value then comes from a later tick.

Since read exists only on the blocks of these three mods, it also tells them apart from other devices. This lists every one the computer can reach, with all its readings:

Brass
for _, name in ipairs(peripheral.list()) do
  local p = peripheral.wrap(name)
  if p and p.read then
    print(name)
    for key, value in pairs(p.read()) do
      print("  " .. key, value)
    end
  end
end

Altitude Sensor

The Altitude Sensor gives off a redstone signal that grows with its height, between two heights you set in its screen. The computer skips that scale and reads the height itself.

#

alt.height()

→ number

The height of the sensor in the world, in blocks: the Y coordinate of the centre of the block.

Returns
number
the height of the centre of the sensor, in blocks (world Y)

On the ground, a sensor sitting on top of a block at Y 64 is itself at Y 65, so it reads 65.5. On a flying ship, it reads the real height of the ship in the world, wherever the ship is. This is the reading an altitude autopilot holds (see Airship altitude hold).

Brass
local alt = peripheral.find("altitude_sensor")
print(string.format("Height: %.1f", alt.height()))

A low altitude alarm: a lamp on top of the computer lights up below Y 90.

Brass
local alt = peripheral.find("altitude_sensor")
while true do
  rs.set("top", alt.height() < 90)
  sleep(0.5)
end

The climb speed comes from two readings: the difference of height divided by the time between them.

Brass
local alt = peripheral.find("altitude_sensor")
local before = alt.height()
sleep(1)
local climb = alt.height() - before
print(string.format("climbing %+.1f blocks/s", climb))

See also altitude_sensor.pressure() vehicle.position()

#

alt.pressure()

→ number

The air pressure where the sensor is: 1 at sea level, less and less as you climb.

Returns
number
the air pressure around the sensor, 1 at sea level

By default the air thins smoothly with height: about 0.71 at Y 150, 0.58 at Y 200, and 0 at the top of the world. Below sea level it goes above 1. Engineer's Goggles show the same value as a percentage. A data pack can change the curve of a dimension.

Pressure matters because balloons lift less in thin air: a ship that floats easily at Y 100 may not be able to climb past Y 250. Show it as a percentage:

Brass
local alt = peripheral.find("altitude_sensor")
print(string.format("Air: %.0f %%", alt.pressure() * 100))

Gimbal Sensor

The Gimbal Sensor measures how much the ship leans. Its value boxes (the angle of maximum signal, the direction of the output) only change its redstone output, not what a computer reads.

Both angles are measured in the ship's own axes: "south" is the side of the ship that faced south (+Z) when it was built, and "east" the side that faced east (+X), whichever way the ship points now. The names of devices on the ship's Data Cable use the same axes, which makes them easy to combine (a burner at a larger X is on the east side).

On the ground, away from any assembled ship, both angles read 0.

#

gyro.angle_x()

→ number

The tilt of the ship around its X axis (the east-west axis), in degrees: the "nose up, nose down" of a ship that flies north or south.

Returns
number
the tilt around the X axis, in degrees; above 0 when the south side is low

0 means level. Above 0, the south side is lower than the north side; below 0, the north side is lower.

Brass
local gyro = peripheral.find("gimbal_sensor")
local x = gyro.angle_x()
if x > 1 then
  print("south side low by " .. x .. " degrees")
elseif x < -1 then
  print("north side low by " .. -x .. " degrees")
else
  print("level north-south")
end

See also gimbal_sensor.angle_z()

#

gyro.angle_z()

→ number

The tilt of the ship around its Z axis (the north-south axis), in degrees: how much it rolls to one side.

Returns
number
the tilt around the Z axis, in degrees; above 0 when the east side is low

0 means level. Above 0, the east side is lower than the west side; below 0, the west side is lower.

The two angles make a bubble level. The bubble floats to the high side, as in a real one, and turns yellow then red as the ship leans more. The drawing takes the table read() returns, so here it is tried with a reading typed by hand (the south side is low by 2.5 degrees, the west side by 4):

Brass
local function level(m)
  gfx.clear("black")
  term.clear()
  local cx, cy, r = 153, 90, 70
  gfx.circle(cx, cy, r, "gray", 2)
  gfx.circle(cx, cy, 12, "light_gray")
  gfx.line(cx - r, cy, cx + r, cy, "gray")
  gfx.line(cx, cy - r, cx, cy + r, "gray")
  -- north is up: east low moves the bubble west, south low moves it north
  local bx = cx - math.max(-60, math.min(60, m.angle_z * 6))
  local by = cy - math.max(-60, math.min(60, m.angle_x * 6))
  local tilt = math.sqrt(m.angle_x ^ 2 + m.angle_z ^ 2)
  local color = "lime"
  if tilt > 5 then
    color = "red"
  elseif tilt > 1 then
    color = "yellow"
  end
  gfx.circle(bx, by, 9, color, true)
  term.set_cursor(1, 1)
  term.write(string.format("X %+.1f", m.angle_x))
  term.set_cursor(1, 2)
  term.write(string.format("Z %+.1f", m.angle_z))
  gfx.text(cx - 1, cy - r - 9, "N", "white")
end

level({angle_x = 2.5, angle_z = -4})
Screen
Screen

On the ship, feed it the real sensor a few times a second (with the level function above in the same file):

Brass
local gyro = peripheral.find("gimbal_sensor")
while true do
  level(gyro.read())
  sleep(0.2)
end

See also gimbal_sensor.angle_x()

Velocity Sensor

#

speedo.velocity()

→ number

The speed of the ship along the axis of the sensor, in blocks per second (Aeronautics writes m/s: the same thing).

Returns
number
the speed of the ship along the sensor's axis, in blocks per second, with a sign

The sensor only measures along its own axis, the way its fan faces: placed along the length of the ship it gives the forward speed, placed upright it gives the climb speed. The sign tells which way along that axis: positive one way, negative the other. Fly forward once to see which sign your sensor gives.

Below 0.05 blocks per second it reads 0, and it always reads 0 away from an assembled ship. Its value box (the speed of maximum signal) only changes its redstone output.

Brass
local speedo = peripheral.find("velocity_sensor")
print(string.format("%.1f blocks/s", math.abs(speedo.velocity())))

A cruise control: the propellers turn through a Rotation Speed Controller behind the computer, and the program speeds them up or slows them down to hold 10 blocks per second. set_speed wants a whole number, hence math.floor. If your sensor reads a negative speed when the ship flies forward, write -speedo.velocity().

Brass
local speedo = peripheral.find("velocity_sensor")
local motor = peripheral.wrap("back")   -- Rotation Speed Controller of the propellers
local CRUISE = 10
local rpm = 64
while true do
  local v = speedo.velocity()
  rpm = math.max(0, math.min(256, rpm + (CRUISE - v) * 2))
  motor.set_speed(math.floor(rpm))
  sleep(0.5)
end
Tip

A computer riding the ship also has vehicle (Personal Computer, Microcontroller, Modern Computer): vehicle.speed is the speed in every direction at once, vehicle.velocity gives it per world axis. The Velocity Sensor is the one to use for one axis of the ship, such as "forward".

See also vehicle.speed() vehicle.velocity()

Optical Sensor

The Optical Sensor shines a laser out of its face (straight up when it sits on a floor, straight down when it hangs under a ceiling), and reports the first block the beam hits. With an item in its filter slot, only matching blocks count: a beam that hits anything else reports nothing.

Point one forward on the bow to spot obstacles, or down under the hull to measure the height above the ground.

#

eye.hit()

→ boolean

Whether the beam hits a block within its range.

Returns
boolean
true when the beam hits a block (one that passes the filter, if there is one)
Brass
local eye = peripheral.find("optical_sensor")
if eye.hit() then
  print("something ahead")
end

See also optical_sensor.distance() optical_sensor.block()

#

eye.distance()

→ number|nil

How far the block is, in blocks, measured from the centre of the sensor to the point where the beam touches the block. nil when the beam hits nothing.

Returns
number|nil
the distance from the centre of the sensor to the point hit, in blocks; nil when nothing is hit

Pointed down under a ship, it is the height above the ground, which the Altitude Sensor cannot give: handy to land gently.

Brass
local eye = peripheral.find("optical_sensor")
local d = eye.distance()
if d then
  print(string.format("ground %.1f blocks below", d))
else
  print("no ground in range")
end

See also optical_sensor.hit() optical_sensor.range()

#

eye.block()

→ string|nil

The id of the block the beam hits, such as "minecraft:oak_log" or "create:andesite_casing". nil when the beam hits nothing.

Returns
string|nil
the id of the block hit, like "minecraft:stone"; nil when nothing is hit

A sensor pointing down finds the landing pad, a square of yellow concrete:

Brass
local eye = peripheral.find("optical_sensor")
if eye.block() == "minecraft:yellow_concrete" then
  print("right above the landing pad")
end

The beam goes through fluids, unless a fluid item is in the filter slot: with a water bucket there, it stops on water (block() gives "minecraft:water") and nothing else counts.

See also optical_sensor.hit()

#

eye.range()

→ number

The longest distance the beam reaches, in blocks: the value box on the sensor. A new sensor starts at the server's maximum, 15 blocks unless the server config optical_sensor_max_range says otherwise.

Returns
number
the length of the beam, in blocks
Brass
local eye = peripheral.find("optical_sensor")
print("beam: " .. eye.range() .. " blocks")

See also optical_sensor.set_range()

#

eye.set_range(blocks)

Changes the length of the beam, like turning its value box. The value is kept between 1 and the server's maximum (15 by default), and the function returns nothing: read range() to see what was kept.

Parameters
blocks number
the new length of the beam, a whole number of blocks

The number must be whole: eye.set_range(7.5) stops the program with bad argument #1 to 'set_range' (number has no integer representation). Round it with math.floor first.

A short beam ignores what is far away, for example an alarm that only cares about the last 6 blocks:

Brass
local eye = peripheral.find("optical_sensor")
eye.set_range(6)
print(eye.range())
eye.set_range(1000)
print(eye.range())   -- the server maximum, 15 by default

An obstacle warning. A sensor on the bow looks ahead, and the computer rings a bell (or lights a lamp) on its top side when something is closer than 8 blocks. read() takes the three values of the same moment:

Brass
local eye = peripheral.find("optical_sensor")
while true do
  local m = eye.read()
  local danger = m.hit and m.distance < 8
  rs.set("top", danger)
  term.clear()
  term.set_cursor(1, 1)
  if danger then
    print("OBSTACLE " .. m.block .. " at " .. m.distance)
  else
    print("clear ahead")
  end
  sleep(0.25)
end

The same reading drawn as a gauge: the bar is the beam, filled up to the obstacle, red when it is close. Here with a reading typed by hand, a tree 6.4 blocks ahead:

Brass
local function radar(m)
  gfx.clear("black")
  term.clear()
  term.set_cursor(2, 2)
  term.write("BOW SENSOR, beam " .. m.range .. " blocks")
  gfx.rect(10, 40, 286, 30, "gray", 2)
  if m.hit then
    local w = math.floor(282 * m.distance / m.range)
    local color = "lime"
    if m.distance < 8 then
      color = "red"
    end
    gfx.rect(12, 42, w, 26, color, true)
    term.set_cursor(2, 10)
    term.write(string.format("%s at %.1f blocks", m.block, m.distance))
  else
    term.set_cursor(2, 10)
    term.write("clear ahead")
  end
end

radar({hit = true, distance = 6.4, block = "minecraft:oak_log", range = 15})
Screen
Screen

See also optical_sensor.range()

The Navigation Table points to the target of the navigation item placed in it: a compass (the world spawn, or its lodestone), a recovery compass (your last death), a map (the nearest marker on it: a structure of an explorer map, or a banner you marked). On its own it sends redstone towards the target; the computer reads the direction and the distance.

Swivel Bearing

The Swivel Bearing turns a structure glued in front of it (it assembles into a contraption when its cog is powered), like a turret or a rotating radar dish. It is also a Create kinetic block, so the wrapped bearing has the methods of Create kinetic blocks as well, such as speed().

#

bearing.target_angle()

→ number

The angle the bearing is turning its structure to, in degrees. The structure follows it physically, a little behind.

Returns
number
the angle the bearing turns its structure to, in degrees

The angle grows (or shrinks, depending on the direction) as the cog turns, and starts again after a full turn: it stays between -360 and 360. angle % 360 brings it between 0 and 360. It is 0 while the bearing is not assembled.

Brass
local bearing = peripheral.find("swivel_bearing")
print(string.format("aiming at %.1f degrees", bearing.target_angle() % 360))

Turning a turret to a heading: a Rotation Speed Controller behind the computer drives the bearing's cog slowly until the angle is within 3 degrees of the goal, then stops. With its cog at 8 RPM, the bearing turns 2.4 degrees per tick, so the loop, which checks every tick, cannot jump over the 6 degree window.

Brass
local bearing = peripheral.find("swivel_bearing")
local motor = peripheral.wrap("back")   -- Rotation Speed Controller of the cog
local GOAL = 90

local function gap(angle)
  return (GOAL - angle + 180) % 360 - 180
end

motor.set_speed(8)
repeat
  sleep(0.05)
until math.abs(gap(bearing.target_angle())) < 3
motor.set_speed(0)

Torsion Spring

The Torsion Spring passes rotation on within a range of angles, then springs back to its starting angle when the input stops (unless redstone holds it). Its value box sets that range, the angle limit. Like the Swivel Bearing, it is also a kinetic block.

#

spring.angle()

→ number

How far the spring is wound now, in degrees.

Returns
number
the current angle of the spring, in degrees
Brass
local spring = peripheral.find("torsion_spring")
print("wound to " .. spring.angle() .. " of " .. spring.limit() .. " degrees")

See also torsion_spring.limit()

#

spring.limit()

→ number

The angle limit set on the value box of the spring, in degrees: 90 on a new spring, from 1 to 360.

Returns
number
the angle limit, from 1 to 360 degrees

See also torsion_spring.set_limit()

#

spring.running()

→ boolean

true while the spring moves (its angle changed during the last tick), false when it is at rest.

Returns
boolean
true while the spring is turning
Brass
local spring = peripheral.find("torsion_spring")
while spring.running() do
  sleep(0.1)
end
print("the spring is at rest")

See also torsion_spring.set_limit()

#

spring.set_limit(degrees)

→ boolean

Changes the angle limit, only while the spring is at rest. When it turns, nothing changes and the function returns false, as in Simulated's own ComputerCraft peripheral: changing the range in the middle of a swing would make it jump.

Parameters
degrees number
the new angle limit, a whole number of degrees
Returns
boolean
true when the limit was set, false when the spring was turning

The value is kept between 1 and 360. Like every whole-number argument, 90.5 stops the program with bad argument #1 to 'set_limit' (number has no integer representation).

Since it can refuse, try again until it accepts. A hatch driven by a spring opens 90 degrees for cargo, 30 for air:

Brass
local spring = peripheral.find("torsion_spring")

local function open_to(degrees)
  while not spring.set_limit(degrees) do
    sleep(0.1)   -- still moving: wait for it to rest
  end
end

open_to(90)
print("limit now " .. spring.limit())

See also torsion_spring.running() torsion_spring.limit()

More blocks of Create Simulated

Five more blocks of Create Simulated answer a computer. They do not measure the flight, but they help a program around the ship: two receivers that tell where a Redstone Link transmitter is, the Docking Connector that tells which ship is docked, the Linked Typewriter that turns a keyboard into a control panel, and the Nameplate that holds the ship's name. Each has read() too, like the sensors above.

#

rx.angle()

→ number

How far from straight ahead the transmitter is, as the Directional Linked Receiver sees it: 0 when the transmitter is right in front of the receiver's face, 90 when it is level with the face, off to one side.

Returns
number
how far off the receiver's axis the transmitter is, in degrees, from 0 (straight ahead) to 90

The receiver has the two frequency slots of a Redstone Link, and looks for a powered transmitter on that frequency (a Redstone Link in transmitter mode). It only sees the transmitters in front of its face, within Create's link range (256 blocks by default), and measures with the real positions in the world: a receiver on a flying ship finds a beacon on the ground. The angle says how far off the axis the transmitter is, not on which side: 30 degrees can be left, right, above or below.

Keep a single transmitter on the frequency: with several, the angle may come from any of those in front of it. When no transmitter is in front of it, the angle keeps its last value.

A landing beacon: a Redstone Link powered by a lever on the landing pad, and the receiver under the hull of the ship, facing down. 0 means right above the pad:

Brass
local rx = peripheral.find("directional_link")
local a = rx.angle()
if a < 5 then
  print("right above the beacon")
else
  print(string.format("beacon %.0f degrees off", a))
end

See also modulating_link.distance()

#

rx.distance()

→ number

The distance from the Modulating Linked Receiver to the nearest powered transmitter on its frequency, in blocks, in a straight line from the centre of one block to the centre of the other, with the real positions in the world.

Returns
number
the distance to the nearest powered transmitter on its frequency, in blocks; 256 when there is none

On its own, the receiver turns that distance into a redstone signal between the Minimum and Maximum Range set in its screen. The computer reads the distance itself, whatever those ranges. It is 256 when no transmitter on the frequency is powered, and never more than 256.

Brass
local rx = peripheral.find("modulating_link")
local d = rx.distance()
if d >= 256 then
  print("no beacon in range")
else
  print(string.format("beacon %.1f blocks away", d))
end

With both receivers under the hull, facing down, on the frequency of the beacon, the ship knows how far it is from the pad sideways and how high above it. The values are typed by hand here (the angle from the Directional Linked Receiver, the distance from the Modulating one):

Brass
local function above_pad(angle, distance)
  local a = angle * math.pi / 180
  return {side = distance * math.sin(a), height = distance * math.cos(a)}
end

local p = above_pad(30, 20)
print(string.format("%.1f blocks to the side, %.1f below", p.side, p.height))
Screen
10.0 blocks to the side, 17.3 below

See also directional_link.angle() vehicle.position()

#

dock.connected_name()

→ string

The name of the vehicle on the other side of the Docking Connector. Two connectors dock face to face: one on a ship and one on another ship, or on a dock on the ground. A connector on the dock reads the name of the ship that came in.

Returns
string
the name of the vehicle docked to this connector; "" when nothing is docked or the vehicle has no name

It is "" when nothing is docked, when the other connector is not on a vehicle (a dock on the ground, seen from the ship), and when the vehicle has no name yet: give it one with a Nameplate.

A dock that tells when a ship arrives and when it leaves:

Brass
local dock = peripheral.find("docking_connector")
local last = ""
while true do
  local name = dock.connected_name()
  if name ~= last then
    if name == "" then
      print(last .. " has left")
    else
      print(name .. " has docked")
    end
    last = name
  end
  sleep(1)
end

See also vehicle.name() name_plate.name()

#

keys.pressed_keys()

→ table

The keys a player holds on the Linked Typewriter right now. A player right-clicks the typewriter to use it, and leaves it with Escape. While they use it, the keys bound on the typewriter go to it instead of moving the player: each one sends its Redstone Link frequency, and the computer reads the keys themselves.

Returns
table
the codes of the keys held on the typewriter now, in the order they were pressed; empty when none

Only bound keys count. A key that has no frequency on the typewriter is not sent to it, so it never shows up here. Bind keys in the typewriter's screen (sneak and right-click it), or right-click it with a Linked Controller: the movement keys (W, A, S, D, Space, Shift) then get the frequencies of the controller.

Each key is a number, the key code of Minecraft's keyboard: 32 Space, 48 to 57 the digits 0 to 9, 65 A to 90 Z (so 87 W, 65 A, 83 S, 68 D), 262 Right arrow, 263 Left, 264 Down, 265 Up. For a letter, string.char(code) gives it back ("W" for 87). The list is empty when nobody uses the typewriter, or when no bound key is held.

Brass
local keys = peripheral.find("linked_typewriter")
for _, code in ipairs(keys.pressed_keys()) do
  print(code)
end

A throttle on the keyboard (with W, S and Space bound): hold W to speed up the propellers, S to slow down and then go backwards, Space to stop. A frequency only acts while its key is held; here the speed stays where you leave it:

Brass
local keys = peripheral.find("linked_typewriter")
local motor = peripheral.wrap("back")   -- Rotation Speed Controller of the propellers

local function held(list, code)
  for _, k in ipairs(list) do
    if k == code then
      return true
    end
  end
  return false
end

local rpm = 0
while true do
  local down = keys.pressed_keys()
  if held(down, 87) then rpm = math.min(256, rpm + 8) end    -- W
  if held(down, 83) then rpm = math.max(-256, rpm - 8) end   -- S
  if held(down, 32) then rpm = 0 end                         -- Space
  motor.set_speed(rpm)
  sleep(0.1)
end
#

plate.name()

→ string

The name on the Nameplate. On a vehicle that has a name, the plate shows that name, so this is the name of the ship: the one vehicle.name() gives on board and docking_connector.connected_name() gives at the dock. "" when there is no name at all.

Returns
string
the name the Nameplate shows; "" when it has none

A row of Nameplates of the same colour side by side shows one name. A plate waxed with a honeycomb is locked: it keeps its own name, and no longer follows the vehicle's.

Brass
local plate = peripheral.find("name_plate")
print("This ship is the " .. plate.name())

See also name_plate.set_name() vehicle.name()

#

plate.set_name(name)

Writes a new name on the Nameplate, as a player does in its screen. On a vehicle, it renames the vehicle too: every Nameplate of the ship, vehicle.name() on board and the docking connectors now see the new name. A waxed plate only changes its own name.

Parameters
name string
the new name, cut to 64 characters (a number is turned into text)

A cargo ship that shows where it is going, in its name:

Brass
local plate = peripheral.find("name_plate")
plate.set_name("Albatross (to the mine)")

See also name_plate.name() vehicle.name()