Advertisement
SemlerPDX

WarningLight

Dec 20th, 2016
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. --Simple Warning Light Program for ComputerCraft
  2. --by SemlerPDX Dec2016
  3. --Relays EnderIO Signal (right) to BluePower Inverted Lamp (left)
  4.  
  5.  
  6. --vars
  7. On = true
  8. Unsafe = false
  9.  
  10.  
  11. --funcs
  12. function fSet()
  13.   term.clear()
  14.   term.setCursorPos(1,1)
  15. end
  16.  
  17. function fOn()
  18.   rs.setOutput("left",false)
  19.   On = true
  20. end
  21.  
  22. function fOff()
  23.   rs.setOutput("left",true)
  24.   On = false
  25. end
  26.  
  27. function fBlink()
  28.   for i = 1, 10 do
  29.     fOn()
  30.     sleep(0.75)
  31.     fOff()
  32.     sleep(0.75)
  33.   end
  34. end
  35.  
  36.  
  37. --mains
  38. function Main()
  39.  
  40.   while true do
  41.    
  42.     Unsafe = rs.getInput("right")
  43.  
  44.     if (Unsafe) and not (On) then
  45.       fSet()
  46.       print("unsafe")
  47.       fBlink()
  48.       fOn()
  49.     end
  50.    
  51.     if not (Unsafe) and (On) then
  52.       fSet()
  53.       print("safe")
  54.       fBlink()
  55.       fOff()
  56.     end
  57.  
  58.     sleep(6)
  59.  
  60.   end
  61.  
  62. end
  63.  
  64.  
  65. --inits
  66. fSet()
  67. print("checking safety...")
  68. sleep(0.75)
  69.  
  70.  
  71. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement