Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function FindCoalSlot()
- for i=1,16 do
- turtle.select(i)
- data = turtle.getItemDetail()
- if data ~= nil then
- if data.name == "minecraft:coal" then
- return true
- end
- end
- end
- return false
- end
- function FindSeedSlot()
- print("Finding Seed Slot")
- for i=1,16 do
- print("i is",i)
- turtle.select(i)
- data = turtle.getItemDetail()
- if data ~= nil then
- if data.name == "minecraft:wheat_seeds" then
- return true
- end
- end
- end
- return false
- end
- function FindCarrotSlot()
- print("Finding Carrot Slot")
- for i=1,16 do
- print("i is",i)
- turtle.select(i)
- data = turtle.getItemDetail()
- if data ~= nil then
- if data.name == "minecraft:carrot" then
- return true
- end
- end
- end
- return false
- end
- function RefillFuel()
- --This will get to a point where this will keep running if there is no coal
- FindCoalSlot()
- turtle.refuel()
- FindSeedSlot()
- end
- function LeftLoop()
- --Orient it for the next pass
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- function RightLoop()
- --Orient it for the next pass
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- function farm(dir)
- for i = 1,9 do
- success,data = turtle.inspectDown()
- if (success) then
- if (data.name == "minecraft:wheat") then
- if (data.metadata == 7) then
- curItem = turtle.getItemDetail()
- if curItem ~= "minecraft:seeds_wheat" then
- FindSeedSlot()
- end
- local dug = false
- while(not dug) do
- print("harvesting wheat")
- dug = turtle.digDown()
- end
- turtle.placeDown()
- end
- elseif (data.name == "minecraft:carrots") then
- if (data.metadata == 7) then
- curItem = turtle.getItemDetail()
- if curItem ~= "minecraft:carrot" then
- FindCarrotSlot()
- end
- local dug = false
- while(not dug) do
- print("harvesting carrots")
- dug = turtle.digDown()
- end
- turtle.placeDown()
- end
- end
- else
- turtle.placeDown()
- end
- turtle.suckDown()
- if (i ~= 9) then
- turtle.forward()
- if turtle.getFuelLevel() < 100 then
- print("Fuel Low! Refilling!")
- RefillFuel()
- end
- end
- end
- if dir == "L" then
- LeftLoop()
- elseif dir == "R" then
- RightLoop()
- else
- print("oof")
- end
- end
- for i = 1,100 do
- --first Pass
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- --second pass
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- farm("R")
- farm("L")
- os.sleep(120)
- end
- farm()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement