Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local t = turtle
- local function dropCheck()
- while true do
- os.sleep(1)
- if t.detect == true then
- t.dig() --clears falling blocks until there are no more blocks in the space ahead
- else
- break
- end
- end
- end
- local function reSupply()
- t.select(15)
- t.turnLeft()
- t.dig()
- t.place()
- for i = 9, 14, 1 do --places red ender chest and gets inventory to place for slots 9-14
- t.select(i)
- t.suck()
- end
- t.select(15)
- t.dig()
- t.turnRight()
- end
- local function clearInventory() --places white ender chest and selects inventory slots 1-8 and places them in it
- t.select(16)
- t.turnRight()
- t.dig()
- t.place()
- for i = 1, 8, 1 do
- t.select(i)
- t.drop()
- end
- t.select(16)
- t.dig()
- t.turnLeft()
- end
- local function matCheck()
- for i = 9, 14, 1 do
- itemCount = t.getItemCount(i)
- t.select(i)
- if itemCount > 0 then
- break end --if slot 14 has less than 64 supply, the resupply function is run
- if t.getItemCount(14) < 64 then
- reSupply()
- end
- end
- end
- local function goingUp()
- blockAbove = false
- repeat
- itemCount = t.getItemCount(8) --checks last open incoming slot and if it has inventory, will clearinventory
- if itemCount > 0 then
- clearInventory()
- end
- matCheck() --Digs up until a block is detected above the turtle
- t.dig()
- dropCheck()
- t.place()
- t.up()
- if t.detectUp() then
- blockAbove = true
- end
- until blockAbove == true
- end
- local function keepGoing()
- t.turnRight()
- flag = true
- if t.detect() then --determines if there is a block to the right of the turtle and stops program
- flag = false --if there is
- end
- t.turnLeft()
- return flag
- end
- local function topDown()
- itemCount = t.getItemCount(16)
- if itemCount > 0 then
- clearInventory()
- end --positions the turtle at the top of a column to start digging down
- matCheck()
- t.dig()
- t.place()
- t.turnRight()
- t.forward()
- t.turnLeft()
- end
- local function goingDown()
- blockBelow = false
- repeat
- itemCount = t.getItemCount(8)
- if itemCount > 0 then --checks inventory and digs down until a block is undearneath
- clearInventory()
- end
- matCheck()
- t.dig()
- t.place()
- t.down()
- if t.detectDown() then
- blockBelow = true
- end
- until blockBelow == true
- end
- local function bottomUp()
- itemCount = t.getItemCount(8)
- if itemCount > 0 then
- clearInventory()
- end --positions the turtle at the bottom of next column to start digging up.
- matCheck()
- t.dig()
- t.place()
- t.turnRight()
- t.forward()
- t.turnLeft()
- end
- --_________________________________END OF FUNCTIONS________________________________________
- while true do
- goingUp()
- if keepGoing() == false
- break
- end
- topDown()
- goingDown()
- if keepGoing() == false
- break
- end
- bottomUp()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement