**This is an old revision of the document!**

Component: Redstone

This component represents a Redstone card.

As of OC 1.3 there is a tier two redstone card. The tier one Redstone Card only supports vanilla redstone functionality (single-line analog redstone). Tier two provides interoperation with other mods' redstone systems (bundled, wireless). For bundled input/output the following mods are supported: RedLogic, Project Red (with Version 1.1), MineFactory Reloaded. For wireless redstone, the following mods are supported: WR-CBE, SlimeVoid's WR.

Component name: redstone.
Callbacks:

  • getInput(side: number): number
    Gets the current ingoing redstone signal from the specified side. Note that the side is relative to the computer's orientation, i.e. sides.south is in front of the computer, not south in the world. Likewise, sides.left is to the left of the computer, so when you look at the computer's front, it'll be to your right.
    If you use mods such as RedLogic the input may exceed the vanilla values of [0, 15].
  • getOutput(side: number): number
    Gets the currently set output on the specified side.
  • setOutput(side: number, value: number): number
    Sets the strength of the redstone signal to emit on the specified side. Returns the new value.
    This can be an arbitrarily large number for mods that support this. For vanilla interaction it is clamped to the interval [0, 15].
  • getBundledInput(side: number, color: number): number
    Like getInput, but for bundled input, reading the value for the channel with the specified API/Colors.
    As of OC 1.3: only available on a tier two redstone card.
  • getBundledOutput(side: number, color: number): number
    Like getOutput, but for bundled output, getting the value for the channel with the specified API/Colors.
    As of OC 1.3: only available on a tier two redstone card.
  • setBundledOutput(side: number, color: number, value: number): number
    Like setOutput, but for bundled output, setting the value for the channel with the specified API/Colors.
    As of OC 1.3: only available on a tier two redstone card.
  • setBundledOutput(side: number, values:table):boolean
    Shortcut to set the value of all colors at once. Expects a table with 16 fields, where the index corresponds with the number of the color as documented in API/Colors. Always returns true.
    Warning: By default, Lua starts indexing tables with 1, so when you enter something along the lines of {15,0,0,[…],0} it doesn't activate white as expected, but orange.
    Manually set your indices to circumvent this.
    As of OC 1.3: only available on a tier two redstone card.
  • getWirelessInput():number
    Get the wireless redstone input.
    Added in OC 1.3. Only available on tier two redstone cards.
  • getWirelessOutput():boolean
    Get the wireless redstone output.
    Added in OC 1.3. Only available on tier two redstone cards.
  • setWirelessOutput(value:boolean):boolean
    Set the wireless redstone output.
    Added in OC 1.3. Only available on tier two redstone cards.
  • getWirelessFrequency():number
    Get the currently set wireless redstone frequency.
    Added in OC 1.3. Only available on tier two redstone cards.
  • setWirelessFrequency(frequency:number):number
    Set the wireless redstone frequency to use.
    Added in OC 1.3. Only available on tier two redstone cards.
  • getWakeThreshold():number
    Gets the current wake-up threshold.
  • setWakeThreshold(threshold:number):number
    Sets the wake-up threshold to the specified number.

Note that for mods such as ProjectRed, low values (such as the vanilla maximum of 15) may not function as expected for simple on/off values (opening a door for example), because they have a larger value range. You may need to use a higher value, such as 255.

Example use:

snippet.lua
local component = require("component")
local sides = require("sides")
local colors = require("colors")
local rs = component.redstone -- get primary redstone component
print(rs.getInput(sides.back))
rs.setBundledOutput(sides.bottom, colors.green, rs.getBundledInput(sides.top, colors.red))