Advertisement
Guest User

startup

a guest
May 24th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.29 KB | None | 0 0
  1. local time = 0
  2. local isonGreen = 0
  3. local isonBlue = 0
  4. local isonYellow = 0
  5. local isonLightBlue =0
  6. local isonWhite = 0
  7. local isdoor = 0
  8.  
  9. redstone.setBundledOutput("top", 0)
  10. redstone.setAnalogOutput("right", 15)
  11.  
  12. function makeOutput()
  13.   local out = 0
  14.   local newrs = 0
  15.   if isdoor ~= 0 then
  16.      out = 5
  17.   else
  18.   if isonGreen ~= 0 then
  19.      out = out + 1
  20.   end
  21.   if isonBlue ~= 0 then
  22.      out = out + 1
  23.   end
  24.   if isonYellow ~= 0 then
  25.      out = out + 1
  26.   end
  27.   if isonWhite ~= 0 then
  28.      out = out + 1
  29.   end
  30.   if isonLightBlue ~= 0 then
  31.      out = out + 1
  32.   end
  33.   end
  34.  
  35.   if out >= 1 then
  36.      newrs = newrs + colors.white  
  37.   end
  38.   if out >= 2 then
  39.     newrs = newrs + colors.orange
  40.   end
  41.   if out >= 3 then
  42.     newrs = newrs + colors.magenta
  43.   end
  44.   if out >= 4 then
  45.     newrs = newrs + colors.lightBlue
  46.   end
  47.   if out >= 5 then
  48.     newrs = newrs + colors.yellow
  49.   end
  50.   redstone.setBundledOutput("top", newrs)
  51.  
  52.   if out >= 5 and isdoor == 0 then
  53.     redstone.setAnalogOutput("right", 0)
  54.     isdoor = os.startTimer(60)
  55.   end
  56.  
  57. end
  58.  
  59. while true do
  60.   local e, data = os.pullEvent()
  61. print("vv" .. e)
  62.  
  63.   if e == "redstone" then
  64.     local out
  65.  
  66.     out = redstone.getAnalogOutput("top")
  67.     out = out + 1
  68.            
  69.     if redstone.testBundledInput("back", colors.yellow) then
  70.        isonYellow = os.startTimer(5)  
  71.     end
  72.     if redstone.testBundledInput("back", colors.blue) then
  73.        isonBlue = os.startTimer(8)
  74.     end
  75.     if redstone.testBundledInput("back", colors.white) then
  76.        isonWhite = os.startTimer(1)
  77.     end
  78.     if redstone.testBundledInput("back", colors.lightBlue) then
  79.        isonLightBlue = os.startTimer(1)
  80.     end
  81.     if redstone.testBundledInput("back", colors.green) then
  82.         isonGreen = os.startTimer(3)
  83.     end  
  84.  
  85.     makeOutput()
  86.   end
  87.   if e == "timer" then
  88.       if data == isonYellow then
  89.         isonYellow = 0
  90.       elseif data == isonBlue then
  91.         isonBlue = 0
  92.       elseif data == isonGreen then
  93.         isonGreen = 0
  94.       elseif data == isonWhite then
  95.         isonWhite = 0
  96.       elseif data == isonLightBlue then
  97.         isonLightBlue = 0
  98.       elseif data == isdoor then
  99.         redstone.setAnalogOutput("right", 12)
  100.         isdoor = 0
  101.       end
  102.      
  103.       makeOutput()      
  104.   end    
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement