Difference between revisions of "Redstone (event)"
From ComputerCraft Wiki
(Added a second more complete example of usage, and how you might treat this event.) |
Smiley43210 (Talk | contribs) m (Fixed spelling, grammar; made an edit to keep consistency) |
||
Line 12: | Line 12: | ||
print("Redstone input changed.") | print("Redstone input changed.") | ||
end | end | ||
− | |output=This will tell one when the redstone event is triggered. Note this doesn't tell you the side of the event. | + | |output=This will tell one when the redstone event is triggered. Note that this doesn't tell you the side of the event. |
}}=== Application === | }}=== Application === | ||
{{Example | {{Example | ||
Line 32: | Line 32: | ||
while true do -- Start an endless loop | while true do -- Start an endless loop | ||
− | os.pullEvent("redstone") -- | + | os.pullEvent("redstone") -- Yield the computer until some redstone changes |
-- We don't care what the event returns, since the first variable will be "redstone" and the rest will be nil. | -- We don't care what the event returns, since the first variable will be "redstone" and the rest will be nil. | ||
− | --Now we check each side to see if it's changed. | + | -- Now we check each side to see if it's changed. |
for side, state in pairs(statelist) do -- Run the lines of code in this loop for each key/value pair in statelist | for side, state in pairs(statelist) do -- Run the lines of code in this loop for each key/value pair in statelist | ||
if rs.getInput(side) ~= state then -- If the side we're checking doesn't match what it was last time we checked then | if rs.getInput(side) ~= state then -- If the side we're checking doesn't match what it was last time we checked then |
Revision as of 17:08, 11 April 2013
This page needs some serious TLC, stat! Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: A demonstration on the use and handling of this event would be beneficial. AfterLifeLochie 16:13, 30 November 2012 (MSK)) |
Event redstone | |
Fired when any Redstone inputs change on any of the sides of the computer. | |
Returned Object 1 | Nothing |
Basic Usage
Application