Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- init
- local attempt = 0
- local curStr = rs.getAnalogInput("left")
- rs.setOutput("bottom",false)
- rs.setOutput("top",false)
- rs.setOutput("right",false)
- -- finish unload
- local function attemptDispense()
- rs.setOutput("right",true) -- attempt dispense
- sleep()
- rs.setOutput("right",false) -- pulsar :P
- sleep(1)
- curStr = rs.getAnalogInput("left")
- end
- local function breakbox()
- rs.setOutput("top",true) -- push piston
- sleep()
- rs.setOutput("bottom",false) -- unlock hopper
- sleep(0.5)
- rs.setOutput("bottom",true) -- relock hopper
- sleep()
- rs.setOutput("top",false) -- retract piston
- sleep()
- end
- local function info(state)
- term.clear()
- term.setCursorPos(1,1)
- term.write("Shulker Box Loader Running")
- term.setCursorPos(1,2)
- term.write("State: " .. state)
- end
- while true do
- curStr = rs.getAnalogInput("left")
- if curStr == 15 then
- breakbox()
- attemptDispense()
- info("Attempting next box")
- attempt = 0
- else
- if (curStr == 0 and rs.getInput("front") and attempt == 0) then
- info("New box in system!")
- attemptDispense()
- attempt = 1
- elseif (not rs.getInput("front")) then
- info("No boxes left in system!")
- else
- info("Loading...")
- end
- end
- sleep()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement