GraySloth

ComputerCraft: 'lamp' turns on lights at night.

Feb 15th, 2013
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.54 KB | None | 0 0
  1. --v1.0 by GraySloth 2013-Feb-15
  2. --variables
  3. local sSide = ("top")
  4. --functions
  5. function clear()
  6.    term.clear()
  7.    term.setCursorPos(1,1)
  8. end
  9.  
  10. function on()
  11.    redstone.setOutput(sSide, true)
  12. end
  13.  
  14. function off()
  15.    redstone.setOutput(sSide, false)
  16. end
  17.  
  18. function pulse()
  19.    on()
  20.    os.sleep(1)
  21.    off()
  22. end
  23. --Main
  24. while true do
  25.    if (os.time() < 6) or (os.time() > 19) then
  26.       on()
  27.       os.sleep(1)
  28.       print("Night")
  29.    else
  30.       off()
  31.       os.sleep(1)
  32.       print("Day")
  33.    end
  34.    os.sleep(1)
  35.    clear()
  36. end
Advertisement
Add Comment
Please, Sign In to add comment