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).
Entity Detector
Section titled “Entity Detector”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".
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".
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".
closest, err = gate.nearest("player")gate.radius()
Read the configured detection radius in blocks (1–16).
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".
hostiles, err = gate.scan("hostile")Weather Station
Section titled “Weather Station”Properties: sky.connected, sky.id, sky.kind, sky.name. They are read-only.
sky.clear()
True when it is not raining in this dimension.
sunny, err = station.clear()sky.raining()
True while it rains or snows in this dimension.
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.
now, err = station.read()sky.thundering()
True during a thunderstorm in this dimension.
storm, err = station.thundering()sky.time()
Read dayTime (0–23999, 0 is sunrise), day, gameTime, isDay, isNight and fixedTime.
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.
if station.weather() is Weather.RAIN { print("Rain!") }Environment Sensor
Section titled “Environment Sensor”Properties: probe.connected, probe.id, probe.kind, probe.name. They are read-only.
probe.biome()
Read the biome ID at the sensor.
biome, err = probe.biome()probe.light()
Read the combined light level (0–15) above the sensor.
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.
here, err = probe.read()probe.skyVisible()
True when the space above the sensor can see the sky.
open, err = probe.skyVisible()Redstone Controller
Section titled “Redstone Controller”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.
power, err = gate.input("north")lamps.inputs()
Read every input face's strength, keyed by face.
levels, err = gate.inputs()lamps.mode(face)
Read whether a face is an "input" or an "output".
mode, err = gate.mode("south")lamps.output(face)
Read the strength this controller emits from a face.
power, err = gate.output("south")lamps.outputs()
Read every output face's strength, keyed by face.
levels, err = gate.outputs()lamps.set(face, strength)
Emit an integer strength from 0 through 15 on an output face.
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.
ok, err = gate.setMode("south", "output")Inventory Module
Section titled “Inventory Module”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.
around, err = module.adjacent()chests.inventories()
List approved faces with name, face and available.
faces, err = module.inventories()chests.inventory(face)
Resolve the approved inventory on a face as an Inventory.
storage, err = module.inventory("north")Inventory
Section titled “Inventory”An approved container, from chests.inventory(face) or inventory.from(name).
storage.contains(item)
Test whether at least one of the item is present.
present, err = storage.contains("minecraft:iron_ingot")storage.count(item)
Count the item ID across its component variants.
count, err = storage.count("minecraft:iron_ingot")storage.fullness()
Read occupied capacity as a fraction between zero and one.
value, err = storage.fullness()storage.getSlot(index)
Read an immutable snapshot of a zero-based slot.
slot, err = storage.getSlot(0)storage.isEmpty()
Test whether every visible slot is empty.
value, err = storage.isEmpty()storage.items()
Total each item ID present, keyed by ID.
value, err = storage.items()storage.moveTo(destination, item, amount)
Move up to 256 items while preserving each component variant.
moved, err = storage.moveTo(output, "minecraft:iron_ingot", 16)storage.occupied()
Count non-empty sided slots.
value, err = storage.occupied()storage.size()
Count sided slots.
value, err = storage.size()Display Module
Section titled “Display Module”Properties: screen.connected, screen.id, screen.kind, screen.name. They are read-only.
screen.clear()
Remove all displayed text.
ok, err = board.clear()screen.lines()
Read the displayed lines.
rows, err = board.lines()screen.setLine(index, text)
Replace one line (0–7), adding empty lines before it when needed.
ok, err = board.setLine(0, "Status: OK")screen.setText(text)
Replace the text: up to 8 lines of 48 characters separated by newlines.
ok, err = board.setText("Iron: 64")screen.text()
Read the displayed text with lines separated by newlines.
shown, err = board.text()screen.write(text)
Show text on the display, replacing what was there. Use for a new line.
board.write("Hello!")Alarm Module
Section titled “Alarm Module”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.
ok, err = siren.activate()siren.active()
True while the alarm is sounding.
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.
ok, err = siren.configure("bell", 80, 20)siren.deactivate()
Silence the alarm.
ok, err = siren.deactivate()siren.settings()
Read sound, volume, seconds, active and remaining seconds.
info, err = siren.settings()Storage Server
Section titled “Storage Server”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.
server.append("visitors", name)records.clear()
Remove everything stored on the server.
server.clear()records.delete(key)
Remove a key. Gives false when nothing was stored.
server.delete("old")records.has(key)
True when something is stored under a key.
if server.has("diamonds") { print("stocked") }records.keys()
List the stored keys, oldest first.
names = server.keys()records.read(key)
Read a copy of the value stored under a key. A missing key gives the error storage.missing.
count = server.read("diamonds")records.usage()
Read used and capacity bytes and entries and maxEntries.
space = server.usage()records.write(key, value)
Store a copy of a value under a key, replacing any old value.
server.write("diamonds", 64)Access Controller
Section titled “Access Controller”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.
names = door.allowed()front_door.close()
Turn the outputs off now.
door.close()front_door.isOpen()
True while the outputs are powered.
if door.isOpen() { print("open") }front_door.isPublic()
True when anyone may open the door.
open = door.isPublic()front_door.open()
Power the outputs for the configured number of seconds, as if access was granted.
door.open()front_door.openFor(seconds)
Power the outputs for 1 to 30 seconds.
door.openFor(10)front_door.recent()
List up to 10 recent attempts, newest first, as text.
for line in door.recent() { print(line) }Control Panel
Section titled “Control Panel”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.
name = panel.label(Button.ONE)panel.labels()
List the four button labels.
names = panel.labels()panel.setLabel(button, label)
Change a button's label: 1 to 24 characters.
panel.setLabel(Button.ONE, "Open Gate")Wireless Network Bridge
Section titled “Wireless Network Bridge”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.
info = link.status()Network Repeater
Section titled “Network Repeater”Properties: hub.connected, hub.id, hub.kind, hub.name. They are read-only.
hub.links()
List directly linked devices with name, id, kind, capabilities and connected.
linked, err = router.links()hub.status()
Summarize links: total, connected and the computer's network ID.
info, err = router.status()Redstone port
Section titled “Redstone port”A named port of a Network Interface, from redstone.from(name).
door.read()
Read current port strength.
power, err = door.read()door.set(strength)
Set an output strength from 0 through 15.
ok, err = door.set(15)