Redstone API

From ComputerCraft
(Redirected from Redstone)
Jump to navigation Jump to search

Redstone.getAnalogInput Redstone.getAnalogOutput Redstone.getAnalogueInput Redstone.getAnalogueOutput Redstone.getBundledInput Redstone.getBundledOutput

FunctionFunctionredstone.getInput
When given a parameter with a valid side, this function will return a boolean value indicating whether the computer or turtle is receiving a redstone signal. Where true corresponds to a present signal and false corresponds to no present signal.
Syntax redstone.getInput()
Returns boolean state of the redstone signal
Part of CC:Tweaked (source)
API redstone
ExampleExampleCheck for receiving sides
Prints any side that is receiving a redstone signal
Code
for key, value in pairs(redstone.getSides()) do
    if (redstone.getInput(value)) then
        print("Side "..value.." is receiving a signal.")
    end
end
Output Side [top, bottom, front, back, left, right] is receiving a signal.


FunctionFunctionredstone.getOutput
When given a parameter with a valid side, this function will return a boolean value indicating whether the computer or turtle is outputting a redstone signal. Where true corresponds to a present signal and false corresponds to no present signal.
Syntax redstone.getOutput()
Returns boolean state of the redstone signal
Part of CC:Tweaked (source)
API redstone
ExampleExampleCheck if outputting signal.
Prints any side that is outputting a signal.
Code
for key, value in pairs(redstone.getSides()) do
    if (redstone.getOutput(value)) then
        print("Side "..value.." is outputting a signal.")
    end
end
Output Side [top, bottom, front, back, left, right] is outputting a signal.


FunctionFunctionredstone.getSides
Searches every side available to the computer or turtle and returns a table of sides that are valid for redstone interaction.
Syntax redstone.getSides()
Returns table of valid sides
Part of CC:Tweaked (source)
API redstone
ExampleExampleCheck for valid sides
Prints any side that is valid for redstone interaction
Code
for key, value in pairs(redstone.getSides()) do
    print("Side "..value.." is valid.")
end
Output Side [top, bottom, front, back, left, right] is valid.

Redstone.setAnalogOutput Redstone.setAnalogueOutput Redstone.setBundledOutput

FunctionFunctionredstone.setOutput
When given a parameter with a valid side, this function will return a boolean value indicating whether the computer or turtle is receiving a redstone signal. Where true corresponds to a present signal and false corresponds to no present signal.
Syntax redstone.setOutput()
Returns nil
Part of CC:Tweaked (source)
API redstone
ExampleExampleCheck for receiving sides
redstone.setOutput sets the redstone output as a boolean, defining whether to send output on the specified side or not.
Code
redstone.setOutput("top", true)
sleep(5)
redstone.setOutput("top", false)
Output Redstone will be on on the top for 5 seconds, and then will be turned off.

Redstone.testBundledInput