Difference between revisions of "Redstone (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(Added note about "rs" versus "redstone".)
m (Added periods, changed capitalization, swapped words around, removed (possibly fake) jargon.)
Line 1: Line 1:
The Redstone API contains methods to control attached RedPower cables/bundled cables and regular 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.
+
The Redstone API contains methods to control attached RedPower cables/bundled cables and regular 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. Refer to the [[Colors]] API for more information on interacting with RedPower's bundled cables.
  
 
<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 10: Line 10:
  
 
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getSides]]()</td>
 
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getSides]]()</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns a table of possible sides</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns a table of possible sides.</td></tr>
  
 
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getInput]]({{type|string}} side)</td>
 
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getInput]]({{type|string}} side)</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the current redstone input signal state on ''side''</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the current redstone input signal state on ''side''.</td></tr>
  
 
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.setOutput]]({{type|string}} side, {{type|boolean}} value)</td>
 
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.setOutput]]({{type|string}} side, {{type|boolean}} value)</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Set or reset a redstone signal on ''side''</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sets or resets a redstone signal on ''side''.</td></tr>
  
 
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getOutput]]({{type|string}} side)</td>
 
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getOutput]]({{type|string}} side)</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the current redstone output signal on ''side''</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the current redstone output signal on ''side''.</td></tr>
  
 
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getAnalogInput]]({{type|string}} side)</td>
 
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getAnalogInput]]({{type|string}} side)</td>
Line 25: Line 25:
  
 
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.setAnalogOutput]]({{type|string}} side, {{type|number}} strength)</td>
 
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.setAnalogOutput]]({{type|string}} side, {{type|number}} strength)</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Set or reset a redstone signal on ''side'' to ''strength''.</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sets or resets a redstone signal on ''side'' to ''strength''.</td></tr>
  
 
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getAnalogOutput]]({{type|string}} side)</td>
 
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.getAnalogOutput]]({{type|string}} side)</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the current redstone output signal strength on ''side''</td></tr>
+
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns the current redstone output signal strength on ''side''.</td></tr>
  
 
<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 of a redpower wire inside a bundle connected to ''side''</td></tr>
+
<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>
  
 
<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 inside a bundle on ''side'' that are being driven high <b>by the local console</b> (not those that are driven high by another device on the bundle but not driven high by the local console)</td></tr>
+
<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>
  
 
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.setBundledOutput]]({{type|string}} side, {{type|int}} colors)</td>
 
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.setBundledOutput]]({{type|string}} side, {{type|int}} colors)</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sets one or multiple colored signals in a redpower bundled wire connected to ''Side''. In order to set multiple signals, add the color values of the colors you want to activate. To turn off all of the values, use 0 for the integer.</td></tr>
+
<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>
  
 
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.testBundledInput]]({{type|string}} side, {{type|int}} color)</td>
 
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[redstone.testBundledInput]]({{type|string}} side, {{type|int}} color)</td>
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns true or false whether or not a colored signal is active in a redpower bundled wire connected to ''side''</td></tr>
+
<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>
  
 
</table>
 
</table>
  
 
[[Category:APIs]]
 
[[Category:APIs]]

Revision as of 09:41, 5 May 2013

The Redstone API contains methods to control attached RedPower cables/bundled cables and regular 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. Refer to the Colors API for more information on interacting with RedPower's bundled cables.

Grid disk.png   Redstone (API)

Method NameDescription
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) 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) Sets or resets a redstone signal on side to strength.
redstone.getAnalogOutput(string side) Returns the current redstone output signal strength on side.
redstone.getBundledInput(string side) Returns the state (as a number) of a RedPower bundled cable connected to side.
redstone.getBundledOutput(string side) Returns the set of RedPower wires in the RedPower bundled cable which are being activated by the terminal on side.
redstone.setBundledOutput(string side, int colors) 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.
redstone.testBundledInput(string side, int color) Returns true if color is active in a RedPower bundled cable attached to side. Else, returns false.