Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- do
- local reserve = turtle.getItemCount(16)
- local fuel = turtle.getFuelLevel()
- write("Checking Resources...\nIf available, place bone meals at slot 14.\n IMPORTANT\nDon't get the item slots mixed up, it's 1 - 16:top-left-right-bottom.\n At least 1 wood of the tree to farm at slot 1.\n Saplings go in slot 15 and source of fuel at slot 16.\n\n\n\n")
- function lackResource()
- write("Lacking Resources\n")
- write("[[Resource Placement]]\nItem\t\t\t\t\t\t\t\t:\tSlot Number\n")
- write("Wood\t\t\t\t\t\t\t\t:\tSlot 1\nBone Meal\t\t\t:\tSlot 14\nSapling\t\t\t\t\t:\tSlot 15\nFuel Source\t:\tSlot 16\n")
- write("Placing other items in these slots will cause unusual turtle behaviour.\n")
- do
- error()
- end
- end
- local sapling = turtle.getItemCount(15)
- local wood = turtle.getItemCount(1)
- if sapling >= 1 and wood >= 1 then
- local function down()
- while not turtle.down() do
- if turtle.detectDown() then
- --#there's a block
- --#we should mine it
- turtle.digDown()
- else
- --#we can assume it's an entity
- --#we should attack it
- turtle.attackDown()
- end
- end
- end
- function reposition()
- turtle.turnRight()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.turnRight()
- turtle.select(1)
- end
- function repositionbone()
- turtle.turnRight()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.turnRight()
- turtle.select(1)
- end
- function surplus()
- surp = turtle.getItemCount(2)
- if surp >= 2 then
- turtle.turnLeft()
- turtle.select(2)
- turtle.drop()
- turtle.turnRight()
- end
- end
- function plantSap()
- if not turtle.detect() then
- turtle.forward()
- end
- if not turtle.detect() then
- turtle.forward()
- end
- if turtle.detect() then
- turtle.select(1)
- fellOrwait()
- end
- if not turtle.detect() then
- sapling = turtle.getItemCount(15)
- if sapling >= 1 then
- turtle.select(15)
- turtle.place()
- turtle.select(1)
- checkBone()
- end
- reposition()
- lackResource()
- end
- end
- function checkBone()
- bone = turtle.getItemCount(14)
- if bone >= 1 then
- turtle.select(1)
- if not turtle.compare() then
- bone = turtle.getItemCount(14)
- if bone >= 1 then
- turtle.select(14)
- turtle.place()
- turtle.select(1)
- end
- fellOrwait()
- end
- if turtle.compare() then
- fellOrwait()
- end
- end
- turtle.select(1)
- fellOrwait()
- end
- function fellOrwait()
- fuel = turtle.getFuelLevel()
- if fuel <= 78 then
- reserve = turtle.getItemCount(16)
- if reserve == 0 then
- write("Out of fuel reserve\n")
- repositionbone()
- lackResource()
- end
- turtle.select(16)
- turtle.refuel(1)
- turtle.select(1)
- end
- if turtle.compare() then
- turtle.dig()
- turtle.forward()
- while turtle.compareUp() do
- turtle.digUp()
- turtle.up()
- end
- while not turtle.detectDown() do
- down()
- end
- sapling = turtle.getItemCount(15)
- if sapling >= 1 then
- turtle.turnLeft()
- turtle.suck()
- turtle.turnRight()
- turtle.turnRight()
- turtle.suck()
- surplus()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- turtle.turnRight()
- turtle.select(15)
- turtle.place()
- turtle.select(1)
- bone = turtle.getItemCount(14)
- if bone >= 1 then
- checkBone()
- end
- repositionbone()
- sleep(180)
- plantSap()
- end
- reposition()
- lackResource()
- end
- if not turtle.compare() then
- bone = turtle.getItemCount(14)
- if bone >= 1 then
- checkBone()
- end
- repositionbone()
- sleep(180)
- print("Waiting for growth!")
- plantSap()
- end
- end
- print("Number of Saplings: " ..sapling.. "\nWood reference checked! OK!\n")
- fuel = turtle.getFuelLevel()
- reserve = turtle.getItemCount(16)
- if fuel <= 79 then
- if reserve == 0 then
- write("NOT ENOUGH FUEL FOR OPERATION\nPLACE FUEL ITEM IN SLOT 16\n")
- lackResource()
- end
- do
- turtle.select(16)
- turtle.refuel(1)
- turtle.select(1)
- fuel = turtle.getFuelLevel()
- print("Fuel Level:" ..fuel.."~\nAll Clear!\nCommencing Automated Logging\n")
- end
- end
- plantSap()
- end
- lackResource()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement