Advertisement
_DudeWhat_

Old Bridge Control

Jul 25th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. monitor = peripheral.wrap("top")
  2. monitor.clear()
  3.  
  4. -- Gets the redstone state
  5. local function RP()
  6.     return redstone.getInput("left")
  7. end
  8.  
  9. local function SetClose()
  10.     monitor.setBackgroundColor(colors.red)
  11.     monitor.clear()
  12.     monitor.setTextColor(colors.lime)
  13.     monitor.setCursorPos(1,1)
  14.     monitor.write("Closing...")
  15.     sleep(12)
  16.     monitor.clear()
  17. end
  18.  
  19. local function SetOpen()
  20.     monitor.setBackgroundColor(colors.red)
  21.     monitor.clear()
  22.     monitor.setTextColor(colors.lime)
  23.     monitor.setCursorPos(1,1)
  24.     monitor.write("Opening...")
  25.     monitor.setCursorPos(1,2)
  26.     monitor.write("Please wait!")
  27.     sleep(12)
  28.     monitor.setBackgroundColor(colors.lime)
  29.     monitor.clear()
  30. end
  31.    
  32. local lastRS = RP()
  33.         if lastRS then
  34. print("Initial State: Opened")
  35.     monitor.setBackgroundColor(colors.lime)
  36.     monitor.clear()
  37.         else
  38. print("Initial State: Closed")
  39.     monitor.setBackgroundColor(colors.red)
  40.     monitor.clear()
  41.         end
  42.  
  43. while true do
  44.     local newRS = RP()
  45.     if not newRS == lastRS then
  46.         lastRS = newRS
  47.         if newRS then
  48. print("Now opening...")
  49.             SetOpen()
  50.         else
  51. print("Now closing...")
  52.             SetClose()
  53.         end
  54.     end
  55.     sleep(0.1)
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement