Advertisement
mindstorm38

EnderIOGrainsFarmer

Apr 6th, 2020
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. local detectSide = "back"
  2. local fireSide = "bottom"
  3. local activeSide = "left"
  4. local count = 8
  5.  
  6. function detect(idx)
  7.     local det = rs.getBundledInput(detectSide)
  8.     return colors.test(det, bit.blshift(1, idx))
  9. end
  10.  
  11. function current(idx)
  12.     local fir = rs.getBundledOutput(fireSide)
  13.     return colors.test(fir, bit.blshift(1, idx))
  14. end
  15.  
  16. function set(idx, fire)
  17.     local fir = rs.getBundledOutput(fireSide)
  18.     local num = bit.blshift(1, idx)
  19.     if fire then
  20.         rs.setBundledOutput(fireSide, colors.combine(fir, num))
  21.     else
  22.         rs.setBundledOutput(fireSide, colors.subtract(fir, num))
  23.     end
  24. end
  25.  
  26. for i=0,(count-1) do
  27.     set(i, false)
  28. end
  29.  
  30. while true do
  31.    
  32.     if rs.getInput(activeSide) then
  33.         for i=0,(count-1) do
  34.        
  35.             if detect(i) then
  36.                 if current(i) then
  37.                     set(i, false)
  38.                     sleep(0.4)
  39.                 end
  40.                 set(i, true)
  41.             end
  42.            
  43.         end
  44.     end
  45.  
  46.     os.pullEvent("redstone")
  47.    
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement