Component: Redstone

This component represents a 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 we currently only support ProjectRed for Minecraft 1.12. In older versions we supported: RedLogic, Project Red (with Version 1.1), MineFactory Reloaded. For wireless redstone, the following mods are supported: WR-CBE, SlimeVoid's WR.

get* and set* method overloads

Starting in patch release 1.7.3 the redstone component provides overloaded flavors of getInput, getOuput, setInput, getBundledInput, getBundledOutput, and setBundledOutput.

get* and set* call costs

The get methods are “direct” calls and are practically free. From testing I was able to call getInput 20,000 to 22,000 times per second.

The set methods are not “direct”, and thus can only be called once per tick, at most. Thus, ~20 times per second. In addition to their indirect cost (consuming the rest of the tick) if the set call changes any output levels, there is an additional delay imposed on the machine. By default set calls can change outputs approximately 6 times per second.

One of the significant advantages of using these overloaded variants is that any api call cost is paid once per call, not once per each value set.

Component name: redstone.
Callbacks:

snippet.lua
lua> component.redstone.getInput(sides.left)
15
lua> component.redstone.getInput(sides.right)
4
lua> component.redstone.getInput()
{[0]=7,
 0,
 0,
 0,
 4,
 15}
lua> component.redstone.getInput()[sides.bottom]
7
snippet.lua
lua> component.redstone.getOutput(sides.left)
7
lua> component.redstone.getOutput() [sides.left]
7
snippet.lua
lua> component.redstone.setBundledOutput(sides.left, { [colors.white] = 15 } ) -- only sets 1 output
lua> component.redstone.setBundledOutput({ [sides.left] = { [colors.white] = 15 } } ) -- same as above

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))