Difference between revisions of "Redstone (API)"
From ComputerCraft Wiki
m (Added a note for the functions that were added in CC1.51 stating that it can only be used in CC1.51 and above) |
Bomb Bloke (Talk | contribs) (Compatible with Minefactory Reloaded RedNet cables as of ComputerCraft 1.53.) |
||
Line 1: | Line 1: | ||
− | The Redstone API contains methods to control attached | + | The Redstone API contains methods to control attached redstone. All methods from the redstone API can also be called using "rs", which points to the same library. For example, instead of redstone.getSides(), rs.getSides() can be used. |
+ | |||
+ | In addition to regular redstone / RedPower cables, RedPower bundled or Minefactory Reloaded RedNet cables may be used to send "bundled" signals out the one face. Refer to the [[Colors]] API for more information on interacting with these. | ||
<table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;"> | <table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;"> | ||
Line 31: | Line 33: | ||
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getBundledInput]]({{type|string}} side)</td> | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getBundledInput]]({{type|string}} side)</td> | ||
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the state (as a number) of a RedPower bundled cable connected to ''side''.</td></tr> | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the state (as a number) of a RedPower bundled / Minefactory Reloaded RedNet cable connected to ''side''.</td></tr> |
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getBundledOutput]]({{type|string}} side)</td> | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getBundledOutput]]({{type|string}} side)</td> | ||
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the set of RedPower wires in the RedPower bundled cable which are being activated by the terminal on ''side''.</td></tr> | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the set of RedPower wires in the RedPower bundled / Minefactory Reloaded RedNet cable which are being activated by the terminal on ''side''.</td></tr> |
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.setBundledOutput]]({{type|string}} side, {{type|number}} colors)</td> | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.setBundledOutput]]({{type|string}} side, {{type|number}} colors)</td> | ||
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sets one or multiple colored signals in a RedPower bundled cable attached to ''side''. ''colors'' will determine which signals are activated. In order to set multiple signals, add the color values of the colors you want to activate. To turn off all of the colors, use 0.</td></tr> | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sets one or multiple colored signals in a RedPower bundled / Minefactory Reloaded RedNet cable attached to ''side''. ''colors'' will determine which signals are activated. In order to set multiple signals, add the color values of the colors you want to activate. To turn off all of the colors, use 0.</td></tr> |
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.testBundledInput]]({{type|string}} side, {{type|number}} color)</td> | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.testBundledInput]]({{type|string}} side, {{type|number}} color)</td> | ||
− | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns true if ''color'' is active in a RedPower bundled cable attached to ''side''. Else, returns false.</td></tr> | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns true if ''color'' is active in a RedPower bundled / Minefactory Reloaded RedNet cable attached to ''side''. Else, returns false.</td></tr> |
</table> | </table> | ||
[[Category:APIs]] | [[Category:APIs]] |
Revision as of 18:57, 15 December 2013
The Redstone API contains methods to control attached redstone. All methods from the redstone API can also be called using "rs", which points to the same library. For example, instead of redstone.getSides(), rs.getSides() can be used.
In addition to regular redstone / RedPower cables, RedPower bundled or Minefactory Reloaded RedNet cables may be used to send "bundled" signals out the one face. Refer to the Colors API for more information on interacting with these.
Method Name | Description |
redstone.getSides() | Returns a table of possible sides. |
redstone.getInput(string side) | Returns the current redstone input signal state on side. |
redstone.setOutput(string side, boolean value) | Sets or resets a redstone signal on side. |
redstone.getOutput(string side) | Returns the current redstone output signal on side. |
redstone.getAnalogInput(string side) | (Requires CC1.51 and above) Returns the current redstone input signal strength on side. If no input is present, returns 0. If a redstone source (such as a redstone torch or block) is directly adjacent to the computer, returns 15. |
redstone.setAnalogOutput(string side, number strength) | (Requires CC1.51 and above) Sets or resets a redstone signal on side to strength (where strength is a positive integer). |
redstone.getAnalogOutput(string side) | (Requires CC1.51 and above) Returns the current redstone output signal strength on side. |
redstone.getBundledInput(string side) | Returns the state (as a number) of a RedPower bundled / Minefactory Reloaded RedNet cable connected to side. |
redstone.getBundledOutput(string side) | Returns the set of RedPower wires in the RedPower bundled / Minefactory Reloaded RedNet cable which are being activated by the terminal on side. |
redstone.setBundledOutput(string side, number colors) | Sets one or multiple colored signals in a RedPower bundled / Minefactory Reloaded RedNet cable attached to side. colors will determine which signals are activated. In order to set multiple signals, add the color values of the colors you want to activate. To turn off all of the colors, use 0. |
redstone.testBundledInput(string side, number color) | Returns true if color is active in a RedPower bundled / Minefactory Reloaded RedNet cable attached to side. Else, returns false. |