Advertisement
Himeki

auto lights

Sep 30th, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. mon = peripheral.wrap( "left" )
  2. readout = "Monitoring"
  3. readout2 = "Monitoring"
  4.  
  5. function clear()
  6.     term.clear()
  7.     term.setCursorPos(1,1)
  8. end
  9.  
  10. function rnd()  --reset and display
  11.     mon.clear()
  12.     mon.setCursorPos(1,1)
  13.     clear()
  14.     sunrise = os.setAlarm(6.00)
  15.     sunset = os.setAlarm(18.00)
  16.     print("Press Q to exit.")
  17.     print(readout2)
  18.     mon.write(readout)
  19. end
  20.  
  21. rnd()
  22.  
  23. while true do
  24.     event, input = os.pullEvent()
  25.     if (event=="alarm") and (input==sunrise) then
  26.         redstone.setOutput("back", false)
  27.         readout = "Good Morning."
  28.         readout2 = "lights out."
  29.         rnd()
  30.         sleep(1)
  31.     elseif (event=="alarm") and (input==sunset) then
  32.         redstone.setOutput("back", true)
  33.         readout = "Good Night."
  34.         readout2 = "lights on."
  35.         rnd()
  36.         sleep(1)
  37.     elseif (event=="key") and (input==16) then -- elseif (event=="char") and ((input=="q") or (input=="Q")) then -- possible change change
  38.         readout2 = "Shutting Down."
  39.         readout = "System standby."
  40.         rnd()
  41.         sleep(1)
  42.         break
  43.     end
  44. end
  45.  
  46. clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement