Advertisement
manaphoenix

ShulkerBox Loader

Aug 29th, 2020
1,863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. -- init
  2. local attempt = 0
  3. local curStr = rs.getAnalogInput("left")
  4.  
  5. rs.setOutput("bottom",false)
  6. rs.setOutput("top",false)
  7. rs.setOutput("right",false)
  8.  
  9. -- finish unload
  10. local function attemptDispense()
  11.     rs.setOutput("right",true) -- attempt dispense
  12.     sleep()
  13.     rs.setOutput("right",false) -- pulsar :P
  14.     sleep(1)
  15.     curStr = rs.getAnalogInput("left")
  16. end
  17.  
  18. local function breakbox()
  19.     rs.setOutput("top",true) -- push piston
  20.     sleep()
  21.     rs.setOutput("bottom",false) -- unlock hopper
  22.     sleep(0.5)
  23.     rs.setOutput("bottom",true) -- relock hopper
  24.     sleep()
  25.     rs.setOutput("top",false) -- retract piston
  26.     sleep()
  27. end
  28.  
  29. local function info(state)
  30.     term.clear()
  31.     term.setCursorPos(1,1)
  32.     term.write("Shulker Box Loader Running")
  33.     term.setCursorPos(1,2)
  34.     term.write("State: " .. state)
  35. end
  36.  
  37. while true do
  38.     curStr = rs.getAnalogInput("left")
  39.     if curStr == 15 then
  40.         breakbox()
  41.         attemptDispense()
  42.         info("Attempting next box")
  43.         attempt = 0
  44.     else
  45.         if (curStr == 0 and rs.getInput("front") and attempt == 0) then
  46.             info("New box in system!")
  47.             attemptDispense()
  48.             attempt = 1
  49.         elseif (not rs.getInput("front")) then
  50.             info("No boxes left in system!")
  51.         else
  52.             info("Loading...")
  53.         end
  54.     end
  55.     sleep()
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement