Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Set up a list which contains the sides as keys, and the current redstone state of each side as a boolean value
- local statelist = {
- ["top"] = rs.getInput("top"),
- ["front"] = rs.getInput("front"),
- ["left"] = rs.getInput("left"),
- ["right"] = rs.getInput("right"),
- ["back"] = rs.getInput("back"),
- ["bottom"] = rs.getInput("bottom"),
- }
- -- Ready the terminal for printing to
- term.clear()
- term.setCursorPos(1,1)
- while true do -- Start an endless loop
- 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.
- -- 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
- if rs.getInput(side) ~= state then -- If the side we're checking doesn't match what it was last time we checked then
- print(side.." is now "..tostring(rs.getInput(side))) -- Print the new state of the side.
- statelist[side] = rs.getInput(side) -- Update the statelist with the new change
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement