Advertisement
jc2xs

Light Controller - Main Lights

Feb 13th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Constants
  2. RS = 'right'
  3. ConstSwitch = colors.red  --  Silo main lights on/off from RS bundle
  4. ConstTone = colors.green  --  Trigger note blocks
  5. lightSequence = {1,3,7,15,31,63,127,255,511,1023,2047,4095}
  6.  
  7. -- Global Variables
  8. BLight = false --  Start with the lights off
  9. redstone.setBundledOutput(RS, 0)
  10.  
  11. function doLightOn()
  12.   for i=1,12 do
  13.     print("lightSequence = "..lightSequence[i])
  14.     redstone.setBundledOutput(RS, lightSequence[i]+ ConstTone)
  15.     sleep(.75)
  16.     redstone.setBundledOutput(RS, lightSequence[i])
  17.   end
  18. end -- doLightOn
  19.  
  20. function doLightOff()
  21.   for i=11,1,-1 do
  22.     print("lightSequence = "..lightSequence[i])
  23.     redstone.setBundledOutput(RS, lightSequence[i] + ConstTone)
  24.     sleep(.75)
  25.     redstone.setBundledOutput(RS, lightSequence[i])
  26.   end
  27.   redstone.setBundledOutput(RS, ConstTone)
  28.   sleep(.75)
  29.   redstone.setBundledOutput(RS, 0)
  30. end -- doLightOff
  31.  
  32.  
  33. while true do
  34.   if bit.band(redstone.getBundledInput(RS), ConstSwitch) == ConstSwitch then
  35.     if BLight == false then
  36.       doLightOn()
  37.       BLight = true
  38.     end -- if
  39.   else
  40.     if BLight == true then
  41.       doLightOff()
  42.       BLight = false
  43.     end -- if
  44.   end  -- if
  45.   print ("BLight = ", BLight)
  46.   sleep(2)
  47. end -- main loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement