Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function checkBlock()
- isBlockDown, blockDown = turtle.inspectDown()
- if isBlockDown and (blockDown.name == "minecraft:wheat" or blockDown.name == "minecraft:carrots") and blockDown.state.age == 7 then
- turtle.digDown()
- turtle.suckDown()
- end
- if (blockDown.name == "minecraft:carrots") then
- turtle.select(3)
- else
- turtle.select(2)
- end
- turtle.placeDown()
- end
- local function refuel()
- turtle.select(16)
- if turtle.getFuelLevel() < 100 then
- --if turtle.getItemCount(1) < 8 then
- --turtle.turnLeft()
- --turtle.suck(56)
- --end
- turtle.refuel()
- end
- os.setComputerLabel("Farming. Fuel: "..turtle.getFuelLevel())
- end
- local function harvest()
- for i=1,4 do
- for j=1,6 do
- turtle.forward()
- checkBlock()
- refuel()
- end
- if i % 2 ~= 0 then
- turtle.turnRight()
- turtle.forward()
- checkBlock()
- turtle.turnRight()
- elseif i % 4 == 0 then
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- checkBlock()
- else
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- checkBlock()
- end
- end
- end
- local function deposit()
- isBlock, block = turtle.inspectDown()
- if isBlock and block.name == "minecraft:chest" then
- for i=1,15 do
- turtle.select(i)
- item = turtle.getItemDetail()
- if item then
- count = item.count
- if i == 2 or i == 3 then
- count = count - 4
- end
- if count > 0 then
- turtle.dropDown(count)
- end
- end
- end
- end
- end
- local function main()
- while true do
- for i=1,2 do
- harvest()
- end
- turtle.back()
- turtle.turnLeft()
- for i=1,10 do
- turtle.forward()
- end
- turtle.turnRight()
- turtle.forward()
- deposit()
- for i=1,480 do
- os.setComputerLabel("Waiting "..480-i.." seconds")
- sleep(1)
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement