Redstone API

Redstone.getAnalogueOutput Redstone.getBundledInput Redstone.getBundledOutput

Functionredstone.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(
  • side : string
)
Returns boolean state of the redstone signal
Part of CC:Tweaked (source)
API redstone
ExampleCheck for receiving sides
Prints any side that is receiving a redstone signal
Code
<nowiki>
for key, value in pairs(redstone.getSides()) do
    if (redstone.getInput(value)) then
        print("Side "..value.." is receiving a signal.")
    end
end
    </nowiki>
Output Side [top, bottom, front, back, left, right] is receiving a signal.
Functionredstone.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(
  • side : string
)
Returns boolean state of the redstone signal
Part of CC:Tweaked (source)
API redstone
ExampleCheck if outputting signal.
Prints any side that is outputting a signal.
Code
<nowiki>
for key, value in pairs(redstone.getSides()) do
    if (redstone.getOutput(value)) then
        print("Side "..value.." is outputting a signal.")
    end
end
    </nowiki>
Output Side [top, bottom, front, back, left, right] is outputting a signal.
Functionredstone.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
ExampleCheck for valid sides
Prints any side that is valid for redstone interaction
Code
<nowiki>
for key, value in pairs(redstone.getSides()) do
    print("Side "..value.." is valid.")
end
    </nowiki>
Output Side [top, bottom, front, back, left, right] is valid.
Functionredstone.getAnalogueInput
When passed a valid side, this function will return a number value indicating the strength of the redstone signal received on that side. If there is no redstone signal it returns 0. Similar to redstone.getInput except it returns the strength instead of boolean on/off status.
Syntax redstone.getAnalogueInput(
  • side : string
)
Returns number strength of the redstone signal
Part of CC:Tweaked (source)
API redstone
ExamplePrint input on each side
Prints the redstone signal strength on each side of the computer.
Code
<nowiki>
for _, side in pairs(redstone.getSides()) do
    print(("redstone signal on %s is %d"):format(side, redstone.getAnalogueInput(side)))
end
    </nowiki>
Output redstone signal on [top, bottom, left, right, front, back] is [0-15]

Redstone.getAnalogOutput

Functionredstone.getAnalogueInput
When passed a valid side, this function will return a number value indicating the strength of the redstone signal received on that side. If there is no redstone signal it returns 0. Similar to redstone.getInput except it returns the strength instead of boolean on/off status.
Syntax redstone.getAnalogueInput(
  • side : string
)
Returns number strength of the redstone signal
Part of CC:Tweaked (source)
API redstone
ExamplePrint input on each side
Prints the redstone signal strength on each side of the computer.
Code
<nowiki>
for _, side in pairs(redstone.getSides()) do
    print(("redstone signal on %s is %d"):format(side, redstone.getAnalogueInput(side)))
end
    </nowiki>
Output redstone signal on [top, bottom, left, right, front, back] is [0-15]

Redstone.setAnalogOutput Redstone.setAnalogueOutput Redstone.setBundledOutput

Functionredstone.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(
  • side : string
  • output : boolean
)
Returns nil
Part of CC:Tweaked (source)
API redstone
ExampleCheck for receiving sides
redstone.setOutput sets the redstone output as a boolean, defining whether to send output on the specified side or not.
Code
<nowiki>
redstone.setOutput("top", true)
sleep(5)
redstone.setOutput("top", false)
    </nowiki>
Output Redstone will be on on the top for 5 seconds, and then will be turned off.

Redstone.testBundledInput

This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.