Skip to content

Redstone Controller

The Redstone Controller block
Redstone Controller. Asset render of the block model, not an in-game screenshot.

The Redstone Controller connects programs to redstone. Each of its six sides is either an input, which reads the power arriving from a lever, button or circuit, or an output, which powers lamps, doors and pistons.

Redstone Controller

Shaped crafting table recipe. Progression: early automation. Ingredients: 4 × Iron Ingot, 2 × Redstone, 2 × Repeater, 1 × Copper Ingot. It appears in the recipe book once you pick up one of its ingredients.

Place it next to the circuit and link it to a Network Repeater. Sides are named by world direction, not by how you placed it: north, south, east, west, up and down, or the constants Direction.NORTH and so on. The arrow on its top points north. Press F3 in Minecraft to see which way you face.

All sides start as inputs. In the form, type a side into Face and select Input or Output. The form lists the current outputs. Programs can also change modes with setMode.

Yes. A drive program uses device.set(...), device.input(...) and the other methods, and receives device.inputChanged, device.signalOn and device.signalOff. The older form on redstone.rising("north") also works there for its own sides.

redstoneControllers.named(alias)

Refer to a Redstone Controller by its name. Use it in a constant, then handle its events with on NAME.event(...).

Parameters: alias: string. Gives: RedstoneController. Cost: 4 operations.

const lamps = redstoneControllers.named("lamps")

redstone.controller(alias)

Resolve a redstone controller by name.

Parameters: alias: string. Gives: RedstoneController, or an error. Errors: device.type, device.unavailable, device.unknown, host.denied. Capability: redstone.read. Cost: 16 operations.

gate, err = redstone.controller("gate")

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")
EventWhen it runs
inputChanged(face, power, previous)Runs when the redstone power arriving at an input face changes. face is a Direction.
signalOn(face, power)Runs when an input face turns on.
signalOff(face)Runs when an input face turns off.
connectedRuns when the device becomes reachable, for example after its area loads.
disconnectedRuns when the device stops being reachable: unloaded, unlinked or removed.
programStartedRuns when the device's own program starts.
programStoppedRuns when the device's own program stops.
programFailed(message)Runs when the device's own program stops on an error.

A named controller’s input sides also raise the older events on redstone.rising("lamps:north"), redstone.falling and redstone.changed in computer programs.

  • Strength is a whole number from 0 to 15. Setting an input side fails with port.mode.
  • Outputs turn off when the controller unloads, loses its connection, or its program stops. They are not restored on load.
  • Output sides are never read as inputs, so a controller cannot trigger itself.
  • Unchanged values cause no block updates.
const lamps = redstoneControllers.named("lamps")
on startup {
lamps.setMode(Direction.SOUTH, PortMode.OUTPUT)
}
on lamps.signalOn(face, power) {
// A lever on any input side turns the south lamps on.
lamps.set(Direction.SOUTH, 15)
}
on lamps.signalOff(face) {
lamps.set(Direction.SOUTH, 0)
}