Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x,y = 0,0
- local direction = "north"
- local fuelTC = 0
- local success, idtable = turtle.inspectDown()
- if success and idtable.name == "minecraft:chest" then
- print("Success")
- else
- error("Need chest below turtle to start farming!")
- end
- function testForAvailableFuel()
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then
- return true
- end
- end
- return false
- end
- function fuelTestCount()
- if fuelTC > 10 then
- fuelTC = fuelTC + 1
- else
- fuelTC = 0
- fuel()
- end
- end
- function fuel()
- local fLimit = turtle.getFuelLimit()
- local fCurr = turtle.getFuelLevel()
- local fSucc = testForAvailableFuel()
- if fCurr >= 5000 then return end
- if fCurr <= math.floor(fLimit/2) and fSucc == true then
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then
- local halfStack = math.floor(turtle.getItemCount(i)/2)
- turtle.refuel(halfStack)
- end
- end
- end
- end
- function forward(dirToGo)
- if dirToGo == "north" then
- y = y + 1
- if direction == "north" then
- turtle.forward()
- elseif direction == "south" then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- elseif direction == "west" then
- turtle.turnRight()
- turtle.forward()
- elseif direction == "east" then
- turtle.turnLeft()
- turtle.forward()
- end
- direction = "north"
- elseif dirToGo == "east" then
- x = x + 1
- if direction == "north" then
- turtle.turnRight()
- turtle.forward()
- elseif direction == "west" then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- elseif direction == "east" then
- turtle.forward()
- elseif direction == "south" then
- turtle.turnLeft()
- turtle.forward()
- end
- direction = "east"
- elseif dirToGo == "south" then
- y = y - 1
- if direction == "south" then
- turtle.forward()
- elseif direction == "north" then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- elseif direction == "east" then
- turtle.turnRight()
- turtle.forward()
- elseif direction == "west" then
- turtle.turnLeft()
- turtle.forward()
- end
- direction = "south"
- elseif dirToGo == "west" then
- x = x - 1
- if direction == "west" then
- turtle.forward()
- elseif direction == "east" then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- elseif direction == "south" then
- turtle.turnRight()
- turtle.forward()
- elseif direction == "north" then
- turtle.turnLeft()
- turtle.forward()
- end
- direction = "west"
- end
- fuelTestCount()
- end
- function moveTo(x2, y2)
- if x2 > x then
- local x3 = x2 - x
- for f = 1, x3 do
- forward("west")
- end
- elseif x2 < x then
- local x3 = math.abs((math.abs(x2)) - x)
- for f = 1, x3 do
- forward("east")
- end
- end
- if y2 > y then
- local y3 = y2 - y
- for g = 1, y3 do
- forward("south")
- end
- elseif y2 < y then
- local y3 = math.abs((math.abs(y2)) - y)
- for g = 1, y3 do
- forward("north")
- end
- end
- end
- function dropOff()
- moveTo(0,0)
- for i = 1, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(1)
- turtle.suckDown()
- end
- function findSeeds()
- for i = 1, 16 do
- turtle.select(i)
- local idtable = turtle.getItemDetail()
- if idtable then
- if idtable.name == "minecraft:wheat_seeds" then
- return i
- end
- end
- end
- end
- function harvestGrownAndPlant()
- local success, idtable = turtle.inspectDown()
- if success then
- if idtable.name == "minecraft:wheat" then
- if idtable.state.age == 7 then
- local seeds = findSeeds()
- turtle.digDown()
- turtle.select(seeds)
- turtle.placeDown()
- end
- end
- end
- local sCurr = turtle.getItemDetail()
- if not sCurr then
- local seeds = findSeeds()
- turtle.select(seeds)
- if turtle.placeDown() then turtle.placeDown() end
- elseif sCurr and sCurr.name ~= "minecraft:wheat_seeds" then
- local seeds = findSeeds()
- turtle.select(seeds)
- if turtle.placeDown() then turtle.placeDown() end
- elseif sCurr and sCurr.name == "minecraft:wheat_seeds" then
- if turtle.placeDown() then turtle.placeDown() end
- end
- end
- function harvestAll()
- for k = 0, 26 do
- for p = 1, 28 do
- moveTo(k, p)
- harvestGrownAndPlant()
- end
- end
- moveTo(0,0)
- end
- while true do
- dropOff()
- harvestAll()
- sleep(600)
- end
Add Comment
Please, Sign In to add comment