druidbruce

CC tweaked create miner main input control

Nov 15th, 2021 (edited)
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | None | 0 0
  1. local vertstate = false --vertical state    back
  2. local oh = false    --horizontal obeserver  left
  3. local ov = false    --vertical obeserver    right
  4. local other = false --other input (for manual/returning control)    top
  5. local full = false  --miner is full         bottom
  6. local function stateout(staten)
  7.     redstone.setAnalogueOutput("front", staten)
  8. end
  9. while true do
  10.     oh = redstone.getInput("left")
  11.     ov = redstone.getInput("right")
  12.     os.sleep(0.1) --every 2 ticks
  13.     vertstate = redstone.getAnalogInput("back")
  14.  
  15.     other = redstone.getAnalogInput("top")
  16.     full = redstone.getInput("bottom")
  17.     if other == 15 then
  18.         stateout(0)
  19.     elseif other == 0 then
  20.         if not full then       
  21.             if vertstate == 10 then
  22.                 stateout(8) -- change
  23.                 print("ostate 8")
  24.             elseif vertstate == 9 then
  25.                 if oh and ov then
  26.                     stateout(7)
  27.                     print("ostate 7")
  28.                 else
  29.                     stateout(6)
  30.                     print("ostate 6")
  31.                 end
  32.            
  33.             elseif vertstate == 1 then
  34.                 stateout(11)
  35.                 print("ostate 11")
  36.             elseif vertstate == 2 then             
  37.                 stateout(4)
  38.                 print("ostate 4")
  39.             elseif vertstate == 8 then
  40.                 stateout(5)
  41.                 print("ostate 5")
  42.             elseif vertstate == 4 then
  43.                 if not oh and not ov then
  44.                     stateout(3)         -- could be 3,9,12
  45.                     print("ostate 3")
  46.                 elseif oh and ov then
  47.                     stateout(13)        --new
  48.                     print("ostate 13")
  49.                 end            
  50.            
  51.            
  52.                
  53.             elseif vertstate == 3 then
  54.                 if not oh and not ov then
  55.                     stateout(1)
  56.                 elseif oh and ov then
  57.                     stateout(2)
  58.                 end    
  59.             elseif vertstate == 5 then 
  60.                 stateout(10)
  61.                
  62.             end
  63.         else        -- full
  64.             stateout(15)
  65.        
  66.         end
  67.     end
  68. end
  69.  
Advertisement
Add Comment
Please, Sign In to add comment