--[[ ======== Botania Livingwood/Livingrock Automation ======== Description: Automates placing and collection of livingwood and livingrock. Will run until either the input is too low or the output is too full Area requirements: 3x4x2 / - Empty D - 1x2 Drawer (Input/Output) 1-8 - Material F - Daisy / D / 2 1 8 3 F 7 4 5 6 N W E S Usage: Ensure the Turtle is properly initialized (name, fuel, etc) Clear out the appropriate space Place Turtle above Input chest facing towards the daisy (South) Run the program --]] -- Check if in correct position local drawer = peripheral.wrap("bottom") if (drawer == nil) then print("couldn't find the drawer, did you place me correctly?") return -- exit if no drawer was found end -- Check if labeled local label = os.getComputerLabel() if not label then print("please first label this turtle using: label ") return end -- Check if fueled local fuel = turtle.getFuelLevel() if fuel < 1 then print("please refuel this turtle using: refuel") return end function getAction(doBreak, doPlace) print("new action break: "..tostring(doBreak).."place: "..tostring(doPlace)) return function() if doBreak then turtle.digDown() end if doPlace then turtle.placeDown() end end end function doCircle(action) -- start: W 1 action() -- [1] turtle.forward() -- 1 -> 2 action() -- [2] turtle.turnLeft() -- W -> S turtle.forward() -- 2 -> 3 action() -- [3] turtle.forward() -- 3 -> 4 action() -- [4] turtle.turnLeft() -- S -> E turtle.forward() -- 4 -> 5 action() -- [5] turtle.forward() -- 5 -> 6 action() -- [6] turtle.turnLeft() -- E -> N turtle.forward() -- 6 -> 7 action() -- [7] turtle.forward() -- 7 -> 8 action() -- [8] turtle.turnLeft() -- N -> W turtle.forward() -- 8 -> 1 -- end: W 1 end function checkInput() -- returns sets local item = drawer.getItemDetail(1) if not item then print("input item was not found") end local stacksize = item.count if stacksize < 8 then return 0 end -- not enough items if stacksize > 64 then stacksize = 64 end local sets = math.floor(stacksize / 8) if (turtle.suckDown(sets * 8)) == false then return 0 end return sets end local amount = -1 local sets = -1 while true do local sets = checkInput() local amount = sets * 8 if sets <= 0 then print("out of items. I need at least 8 input items, please refill and refuel") return -- exit if not enough items end -- Get in position turtle.forward() turtle.turnRight() for i = 0, sets, 1 do print("set "..i.."/"..sets) local action = getAction(i > 0, i <= sets) -- Place and harvest the blocks doCircle(action) -- Wait for the blocks to change sleep(53) end -- Move to deposit turtle.turnRight() turtle.forward() turtle.turnRight() turtle.turnRight() if turtle.dropDown(amount) == false then print("output is full, please put me back on the drawer facing towards the daisy and empty my inventory") return -- exit if output is full end end