Advertisement
jc2xs

Light Controller

Feb 8th, 2016
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. -- Constants
  2. RSFlash = 'bottom'
  3. ConstDoor = colors.red  --  Silo door open/closed read from RSInput bundle
  4. lightSequence = {3,6,12,9}
  5.  
  6. -- Global Variables
  7. curLight = 1
  8. BDoor = false --  Start with the flashing light off and silo door closed
  9.  
  10. function doFlash()
  11.   print("lightSequence = ", lightSequence[curLight])
  12.   redstone.setBundledOutput(RSFlash, lightSequence[curLight])
  13.   curLight = curLight + 1
  14.   if curLight > 4 then
  15.     curLight = 1
  16.   end
  17. end -- doFlash
  18.  
  19. -- Main Loop
  20. while true do
  21.   print ("RSFlash = ", redstone.getBundledInput(RSFlash))
  22.   if bit.band(redstone.getBundledInput(RSFlash), ConstDoor) == ConstDoor then
  23.     BDoor = true
  24.   else
  25.     BDoor = false
  26.   end
  27.   print ("BDoor = ", BDoor)
  28.   if BDoor == true then
  29.     doFlash()
  30.   else
  31.     redstone.setBundledOutput(RSFlash, 0)
  32.   end
  33.   sleep(.4)
  34. end -- main loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement