Skip to content

Hardware objects

Every device’s methods in one place. The hardware pages explain each device with examples. Call methods on a reference or handle, such as gate.count(Entity.HOSTILE). In a drive program, call the device’s own methods on device, such as device.count(Entity.HOSTILE).

Properties: gate.connected, gate.id, gate.kind, gate.name. They are read-only.

gate.census(filter)

Count matches and say whether the scan was cut short: count, truncated (true when more than 256 entities were in range, so count is a lower bound) and nearest (a match or nil). Filters: Entity.ALL, Entity.PLAYER, Entity.HOSTILE, Entity.PASSIVE, Entity.ITEM, Entity.OTHER or an entity type ID such as "minecraft:zombie".

Parameters: filter: enum or string. Gives: dict, or an error. Errors: argument.invalid, detector.busy, device.type, device.unavailable, device.unknown, host.denied. Capability: detector.read. Cost: 32 operations.

seen, err = gate.census("hostile")

gate.count(filter)

Count matching entities within the radius. At most 256 entities are examined; use census to learn whether a count was cut short. Filters: Entity.ALL, Entity.PLAYER, Entity.HOSTILE, Entity.PASSIVE, Entity.ITEM, Entity.OTHER or an entity type ID such as "minecraft:zombie".

Parameters: filter: enum or string. Gives: number, or an error. Errors: argument.invalid, detector.busy, device.type, device.unavailable, device.unknown, host.denied. Capability: detector.read. Cost: 32 operations.

zombies, err = gate.count("minecraft:zombie")

gate.nearest(filter)

Describe the nearest matching entity, or nil when none is present. Filters: Entity.ALL, Entity.PLAYER, Entity.HOSTILE, Entity.PASSIVE, Entity.ITEM, Entity.OTHER or an entity type ID such as "minecraft:zombie".

Parameters: filter: enum or string. Gives: dict, or an error. Errors: argument.invalid, detector.busy, device.type, device.unavailable, device.unknown, host.denied. Capability: detector.read. Cost: 32 operations.

closest, err = gate.nearest("player")

gate.radius()

Read the configured detection radius in blocks (1–16).

Gives: number, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: detector.read. Cost: 4 operations.

radius, err = gate.radius()

gate.scan(filter)

List up to 32 matching entities, nearest first, with type, category, x, y, z, distance and name for players or named entities. Filters: Entity.ALL, Entity.PLAYER, Entity.HOSTILE, Entity.PASSIVE, Entity.ITEM, Entity.OTHER or an entity type ID such as "minecraft:zombie".

Parameters: filter: enum or string. Gives: list, or an error. Errors: argument.invalid, detector.busy, device.type, device.unavailable, device.unknown, host.denied. Capability: detector.read. Cost: 32 operations.

hostiles, err = gate.scan("hostile")

Properties: sky.connected, sky.id, sky.kind, sky.name. They are read-only.

sky.clear()

True when it is not raining in this dimension.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 8 operations.

sunny, err = station.clear()

sky.raining()

True while it rains or snows in this dimension.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 8 operations.

wet, err = station.raining()

sky.read()

Read global weather (raining, thundering, clear, rain and thunder levels), local precipitation and wet at the station, and time of day.

Gives: dict, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 32 operations.

now, err = station.read()

sky.thundering()

True during a thunderstorm in this dimension.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 8 operations.

storm, err = station.thundering()

sky.time()

Read dayTime (0–23999, 0 is sunrise), day, gameTime, isDay, isNight and fixedTime.

Gives: dict, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 16 operations.

clock, err = station.time()

sky.weather()

Read the weather in this dimension: Weather.CLEAR, Weather.RAIN or Weather.THUNDER. Use read() for rain at the station itself.

Gives: enum, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: weather.read. Cost: 8 operations.

if station.weather() is Weather.RAIN { print("Rain!") }

Properties: probe.connected, probe.id, probe.kind, probe.name. They are read-only.

probe.biome()

Read the biome ID at the sensor.

Gives: string, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: environment.read. Cost: 8 operations.

biome, err = probe.biome()

probe.light()

Read the combined light level (0–15) above the sensor.

Gives: number, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: environment.read. Cost: 8 operations.

light, err = probe.light()

probe.read()

Read conditions in the space above the sensor: blockLight, skyLight, light, skyVisible, biome, temperature (unitless biome value), precipitation, position and aboveSeaLevel.

Gives: dict, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: environment.read. Cost: 32 operations.

here, err = probe.read()

probe.skyVisible()

True when the space above the sensor can see the sky.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: environment.read. Cost: 8 operations.

open, err = probe.skyVisible()

Properties: lamps.connected, lamps.id, lamps.kind, lamps.name. They are read-only.

lamps.input(face)

Read the redstone strength (0–15) arriving at a face.

Parameters: face: enum or string. Gives: number, or an error. Errors: argument.invalid, device.type, device.unavailable, device.unknown, host.denied, world.unloaded. Capability: redstone.read. Cost: 12 operations.

power, err = gate.input("north")

lamps.inputs()

Read every input face's strength, keyed by face.

Gives: dict, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied, world.unloaded. Capability: redstone.read. Cost: 24 operations.

levels, err = gate.inputs()

lamps.mode(face)

Read whether a face is an "input" or an "output".

Parameters: face: enum or string. Gives: string, or an error. Errors: argument.invalid, device.type, device.unavailable, device.unknown, host.denied. Capability: redstone.read. Cost: 4 operations.

mode, err = gate.mode("south")

lamps.output(face)

Read the strength this controller emits from a face.

Parameters: face: enum or string. Gives: number, or an error. Errors: argument.invalid, device.type, device.unavailable, device.unknown, host.denied. Capability: redstone.read. Cost: 8 operations.

power, err = gate.output("south")

lamps.outputs()

Read every output face's strength, keyed by face.

Gives: dict, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: redstone.read. Cost: 12 operations.

levels, err = gate.outputs()

lamps.set(face, strength)

Emit an integer strength from 0 through 15 on an output face.

Parameters: face: enum or string, strength: number. Gives: bool, or an error. Errors: argument.invalid, argument.range, device.type, device.unavailable, device.unknown, host.denied, port.mode, world.unloaded. Capability: redstone.write. Cost: 30 operations.

ok, err = gate.set("south", 15)

lamps.setMode(face, mode)

Make a face an "input" or an "output". Leaving output mode turns the face off.

Parameters: face: enum or string, mode: enum or string. Gives: bool, or an error. Errors: argument.invalid, device.type, device.unavailable, device.unknown, host.denied. Capability: redstone.write. Cost: 30 operations.

ok, err = gate.setMode("south", "output")

Properties: chests.connected, chests.id, chests.kind, chests.name. They are read-only.

chests.adjacent()

List neighboring blocks with face, block ID and whether they expose items.

Gives: list, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied, world.unloaded. Capability: inventory.read. Cost: 16 operations.

around, err = module.adjacent()

chests.inventories()

List approved faces with name, face and available.

Gives: list, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: inventory.read. Cost: 16 operations.

faces, err = module.inventories()

chests.inventory(face)

Resolve the approved inventory on a face as an Inventory.

Parameters: face: enum or string. Gives: handle, or an error. Errors: argument.invalid, device.type, device.unavailable, device.unknown, host.denied, inventory.limit, inventory.missing, inventory.stale, inventory.unavailable, inventory.unknown, inventory.unsupported, world.unloaded. Capability: inventory.read. Cost: 16 operations.

storage, err = module.inventory("north")

An approved container, from chests.inventory(face) or inventory.from(name).

storage.contains(item)

Test whether at least one of the item is present.

Parameters: item: string. Gives: bool, or an error. Errors: device.unavailable, host.denied, inventory.limit, inventory.missing, inventory.stale, inventory.unavailable, inventory.unknown, inventory.unsupported, item.identifier, item.unknown, world.unloaded. Capability: inventory.read. Cost: 12 operations.

present, err = storage.contains("minecraft:iron_ingot")

storage.count(item)

Count the item ID across its component variants.

Parameters: item: string. Gives: number, or an error. Errors: device.unavailable, host.denied, inventory.limit, inventory.missing, inventory.stale, inventory.unavailable, inventory.unknown, inventory.unsupported, item.identifier, item.unknown, world.unloaded. Capability: inventory.read. Cost: 12 operations.

count, err = storage.count("minecraft:iron_ingot")

storage.fullness()

Read occupied capacity as a fraction between zero and one.

Gives: number, or an error. Errors: device.unavailable, host.denied, inventory.limit, inventory.missing, inventory.stale, inventory.unavailable, inventory.unknown, inventory.unsupported, world.unloaded. Capability: inventory.read. Cost: 12 operations.

value, err = storage.fullness()

storage.getSlot(index)

Read an immutable snapshot of a zero-based slot.

Parameters: index: number. Gives: dict, or an error. Errors: argument.range, device.unavailable, host.denied, inventory.limit, inventory.missing, inventory.stale, inventory.unavailable, inventory.unknown, inventory.unsupported, world.unloaded. Capability: inventory.read. Cost: 12 operations.

slot, err = storage.getSlot(0)

storage.isEmpty()

Test whether every visible slot is empty.

Gives: bool, or an error. Errors: device.unavailable, host.denied, inventory.limit, inventory.missing, inventory.stale, inventory.unavailable, inventory.unknown, inventory.unsupported, world.unloaded. Capability: inventory.read. Cost: 12 operations.

value, err = storage.isEmpty()

storage.items()

Total each item ID present, keyed by ID.

Gives: dict, or an error. Errors: device.unavailable, host.denied, inventory.limit, inventory.missing, inventory.stale, inventory.unavailable, inventory.unknown, inventory.unsupported, world.unloaded. Capability: inventory.read. Cost: 12 operations.

value, err = storage.items()

storage.moveTo(destination, item, amount)

Move up to 256 items while preserving each component variant.

Parameters: destination: Inventory, item: string, amount: number. Gives: number, or an error. Errors: argument.range, device.unavailable, host.denied, inventory.limit, inventory.missing, inventory.same, inventory.stale, inventory.unavailable, inventory.unknown, inventory.unsupported, item.identifier, item.unknown, world.unloaded. Capability: inventory.transfer. Cost: 24 operations.

moved, err = storage.moveTo(output, "minecraft:iron_ingot", 16)

storage.occupied()

Count non-empty sided slots.

Gives: number, or an error. Errors: device.unavailable, host.denied, inventory.limit, inventory.missing, inventory.stale, inventory.unavailable, inventory.unknown, inventory.unsupported, world.unloaded. Capability: inventory.read. Cost: 12 operations.

value, err = storage.occupied()

storage.size()

Count sided slots.

Gives: number, or an error. Errors: device.unavailable, host.denied, inventory.limit, inventory.missing, inventory.stale, inventory.unavailable, inventory.unknown, inventory.unsupported, world.unloaded. Capability: inventory.read. Cost: 12 operations.

value, err = storage.size()

Properties: screen.connected, screen.id, screen.kind, screen.name. They are read-only.

screen.clear()

Remove all displayed text.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: display.write. Cost: 8 operations.

ok, err = board.clear()

screen.lines()

Read the displayed lines.

Gives: list, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: display.read. Cost: 8 operations.

rows, err = board.lines()

screen.setLine(index, text)

Replace one line (0–7), adding empty lines before it when needed.

Parameters: index: number, text: string. Gives: bool, or an error. Errors: argument.range, device.type, device.unavailable, device.unknown, host.denied. Capability: display.write. Cost: 16 operations.

ok, err = board.setLine(0, "Status: OK")

screen.setText(text)

Replace the text: up to 8 lines of 48 characters separated by newlines.

Parameters: text: string. Gives: bool, or an error. Errors: argument.range, device.type, device.unavailable, device.unknown, host.denied. Capability: display.write. Cost: 16 operations.

ok, err = board.setText("Iron: 64")

screen.text()

Read the displayed text with lines separated by newlines.

Gives: string, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: display.read. Cost: 8 operations.

shown, err = board.text()

screen.write(text)

Show text on the display, replacing what was there. Use for a new line.

Parameters: text: string. Gives: bool, or an error. Errors: argument.range, device.type, device.unavailable, device.unknown, host.denied. Capability: display.write. Cost: 16 operations.

board.write("Hello!")

Properties: siren.connected, siren.id, siren.kind, siren.name. They are read-only.

siren.activate()

Sound the alarm for its configured duration, renewing it when already active.

Gives: bool, or an error. Errors: alarm.limit, device.type, device.unavailable, device.unknown, host.denied. Capability: alarm.write. Cost: 32 operations.

ok, err = siren.activate()

siren.active()

True while the alarm is sounding.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: alarm.write. Cost: 4 operations.

on, err = siren.active()

siren.configure(sound, volume, seconds)

Set sound (bell, pling, chime or bass), volume (10–100) and duration in seconds (1–60). Applies from the next activation or sound.

Parameters: sound: enum or string, volume: number, seconds: number. Gives: bool, or an error. Errors: argument.range, device.type, device.unavailable, device.unknown, host.denied. Capability: alarm.write. Cost: 16 operations.

ok, err = siren.configure("bell", 80, 20)

siren.deactivate()

Silence the alarm.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: alarm.write. Cost: 16 operations.

ok, err = siren.deactivate()

siren.settings()

Read sound, volume, seconds, active and remaining seconds.

Gives: dict, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: alarm.write. Cost: 8 operations.

info, err = siren.settings()

Properties: records.connected, records.id, records.kind, records.name. They are read-only.

records.append(key, value)

Add a value to the end of the list under a key, creating the list when needed.

Parameters: key: string, value: any value. Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied, storage.damaged, storage.full, storage.key, storage.missing, storage.type, storage.value. Capability: server.write. Cost: 24 operations.

server.append("visitors", name)

records.clear()

Remove everything stored on the server.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied, storage.damaged, storage.full, storage.key, storage.missing, storage.type, storage.value. Capability: server.write. Cost: 24 operations.

server.clear()

records.delete(key)

Remove a key. Gives false when nothing was stored.

Parameters: key: string. Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied, storage.damaged, storage.full, storage.key, storage.missing, storage.type, storage.value. Capability: server.write. Cost: 24 operations.

server.delete("old")

records.has(key)

True when something is stored under a key.

Parameters: key: string. Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied, storage.damaged, storage.full, storage.key, storage.missing, storage.type, storage.value. Capability: server.read. Cost: 24 operations.

if server.has("diamonds") { print("stocked") }

records.keys()

List the stored keys, oldest first.

Gives: list, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied, storage.damaged, storage.full, storage.key, storage.missing, storage.type, storage.value. Capability: server.read. Cost: 24 operations.

names = server.keys()

records.read(key)

Read a copy of the value stored under a key. A missing key gives the error storage.missing.

Parameters: key: string. Gives: any value, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied, storage.damaged, storage.full, storage.key, storage.missing, storage.type, storage.value. Capability: server.read. Cost: 24 operations.

count = server.read("diamonds")

records.usage()

Read used and capacity bytes and entries and maxEntries.

Gives: dict, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied, storage.damaged, storage.full, storage.key, storage.missing, storage.type, storage.value. Capability: server.read. Cost: 24 operations.

space = server.usage()

records.write(key, value)

Store a copy of a value under a key, replacing any old value.

Parameters: key: string, value: any value. Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied, storage.damaged, storage.full, storage.key, storage.missing, storage.type, storage.value. Capability: server.write. Cost: 24 operations.

server.write("diamonds", 64)

Properties: front_door.connected, front_door.id, front_door.kind, front_door.name. They are read-only.

front_door.allowed()

List the names of players on the access list.

Gives: list, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: access.control. Cost: 8 operations.

names = door.allowed()

front_door.close()

Turn the outputs off now.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: access.control. Cost: 16 operations.

door.close()

front_door.isOpen()

True while the outputs are powered.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: access.control. Cost: 4 operations.

if door.isOpen() { print("open") }

front_door.isPublic()

True when anyone may open the door.

Gives: bool, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: access.control. Cost: 4 operations.

open = door.isPublic()

front_door.open()

Power the outputs for the configured number of seconds, as if access was granted.

Gives: bool, or an error. Errors: access.limit, device.type, device.unavailable, device.unknown, host.denied. Capability: access.control. Cost: 24 operations.

door.open()

front_door.openFor(seconds)

Power the outputs for 1 to 30 seconds.

Parameters: seconds: number. Gives: bool, or an error. Errors: access.limit, argument.range, device.type, device.unavailable, device.unknown, host.denied. Capability: access.control. Cost: 24 operations.

door.openFor(10)

front_door.recent()

List up to 10 recent attempts, newest first, as text.

Gives: list, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: access.control. Cost: 8 operations.

for line in door.recent() { print(line) }

Properties: panel.connected, panel.id, panel.kind, panel.name. They are read-only.

panel.label(button)

Read one button's label. Use Button.ONE to Button.FOUR or 1 to 4.

Parameters: button: enum or number. Gives: string, or an error. Errors: argument.range, device.type, device.unavailable, device.unknown, host.denied. Capability: panel.control. Cost: 4 operations.

name = panel.label(Button.ONE)

panel.labels()

List the four button labels.

Gives: list, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: panel.control. Cost: 4 operations.

names = panel.labels()

panel.setLabel(button, label)

Change a button's label: 1 to 24 characters.

Parameters: button: enum or number, label: string. Gives: bool, or an error. Errors: argument.range, device.type, device.unavailable, device.unknown, host.denied. Capability: panel.control. Cost: 16 operations.

panel.setLabel(Button.ONE, "Open Gate")

Properties: link.connected, link.id, link.kind, link.name. They are read-only.

link.status()

Describe the pairing: paired, peer (its name), connected and distance in blocks.

Gives: dict, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: devices.read. Cost: 16 operations.

info = link.status()

Properties: hub.connected, hub.id, hub.kind, hub.name. They are read-only.

List directly linked devices with name, id, kind, capabilities and connected.

Gives: list, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: devices.read. Cost: 16 operations.

linked, err = router.links()

hub.status()

Summarize links: total, connected and the computer's network ID.

Gives: dict, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: devices.read. Cost: 16 operations.

info, err = router.status()

A named port of a Network Interface, from redstone.from(name).

door.read()

Read current port strength.

Gives: number, or an error. Errors: device.unavailable, host.denied, port.unknown, world.unloaded. Capability: redstone.read. Cost: 12 operations.

power, err = door.read()

door.set(strength)

Set an output strength from 0 through 15.

Parameters: strength: number. Gives: bool, or an error. Errors: argument.range, device.unavailable, host.denied, port.mode, port.unknown, world.unloaded. Capability: redstone.write. Cost: 30 operations.

ok, err = door.set(15)