Advertisement
Leonic

s

Jul 30th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. -- Set up a list which contains the sides as keys, and the current redstone state of each side as a boolean value
  2. local statelist = {
  3.   ["top"] = rs.getInput("top"),
  4.   ["front"] = rs.getInput("front"),
  5.   ["left"] = rs.getInput("left"),
  6.   ["right"] = rs.getInput("right"),
  7.   ["back"] = rs.getInput("back"),
  8.   ["bottom"] = rs.getInput("bottom"),
  9. }
  10.  
  11. -- Ready the terminal for printing to
  12. term.clear()
  13. term.setCursorPos(1,1)
  14.  
  15. while true do -- Start an endless loop
  16.   os.pullEvent("redstone") -- Yield the computer until some redstone changes
  17.   -- We don't care what the event returns, since the first variable will be "redstone" and the rest will be nil.
  18.  
  19.   -- Now we check each side to see if it's changed.
  20.   for side, state in pairs(statelist) do -- Run the lines of code in this loop for each key/value pair in statelist
  21.     if rs.getInput(side) ~= state then -- If the side we're checking doesn't match what it was last time we checked then
  22.       print(side.." is now "..tostring(rs.getInput(side))) -- Print the new state of the side.
  23.       statelist[side] = rs.getInput(side) -- Update the statelist with the new change
  24.     end
  25.   end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement