Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tArgs = { ... }
- print("Farming in progress...")
- --Assume the turtle has started at the chest facing the wheat
- while true do
- if turtle.getFuelLevel() < 500 then
- print("Fuel level low, returning to base...")
- --Refueling code here
- end
- turtle.forward()
- turtle.up()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- --Wheat row 1 & 2 & carrot row 1
- for i=1,3 do
- if i>=2 then
- k = 1
- else
- k = 0
- end
- for j=0,(11+k) do
- local success, data = turtle.inspectDown()
- if success then
- if (tonumber(data.metadata) >= 7) then
- turtle.digDown()
- turtle.suckDown()
- turtle.digDown()
- if i<3 then
- if assert(loadfile("inv_search"))("minecraft:wheat_seeds") then
- turtle.placeDown()
- end
- else
- if assert(loadfile("inv_search"))("minecraft:carrot") then
- turtle.placeDown()
- end
- end
- end
- else
- turtle.digDown()
- --Call select item subroutine
- turtle.placeDown()
- end
- turtle.forward()
- end
- if i==3 then
- turtle.turnLeft()
- print(turtle.forward())
- os.sleep(0.1)
- print(turtle.forward())
- print("OHSHIT")
- turtle.turnLeft()
- break
- end
- if (i % 2)~=0 then
- turtle.turnLeft()
- turtle.forward()
- print("LEFT")
- turtle.forward()
- turtle.turnLeft()
- else
- turtle.turnRight()
- turtle.forward()
- print("RIGHT")
- turtle.forward()
- turtle.turnRight()
- end
- end
- --Melon row
- turtle.forward()
- for i=1,2 do
- for j=1,4 do
- local success, data = turtle.inspectDown()
- if success then
- if data.name == 'minecraft:melon_block' then
- turtle.digDown()
- turtle.suckDown()
- turtle.digDown()
- end
- end
- turtle.forward()
- end
- if i==1 then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- else
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- end
- end
- --Carrot row 2 & potato rows 1 & 2
- for i=1,3 do
- if i~=3 then
- k = 2
- else
- k = 0
- end
- for j=0,(11+k) do
- local success, data = turtle.inspectDown()
- if success then
- if (tonumber(data.metadata) >= 7) then
- turtle.digDown()
- turtle.suckDown()
- turtle.digDown()
- if i==1 then
- if assert(loadfile("inv_search"))("minecraft:carrot") then
- turtle.placeDown()
- end
- else
- if assert(loadfile("inv_search"))("minecraft:potato") then
- turtle.placeDown()
- end
- end
- end
- else
- turtle.digDown()
- --Call select item subroutine
- turtle.placeDown()
- end
- turtle.forward()
- end
- if i==3 then
- turtle.turnRight()
- turtle.turnRight()
- for l=1,13 do
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.down()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- break
- end
- if (i % 2)~=0 then
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- else
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- end
- end
- --Drop off food & send message to greenhouse controller
- print("Farming complete! Going to sleep for a bit...")
- assert(loadfile("inv_search"))("minecraft:potato")
- turtle.dropUp(turtle.getItemCount()-2)
- assert(loadfile("inv_search"))("minecraft:carrot")
- turtle.dropUp(turtle.getItemCount()-2)
- assert(loadfile("inv_search"))("minecraft:wheat")
- turtle.dropUp(turtle.getItemCount())
- assert(loadfile("inv_search"))("minecraft:melon")
- turtle.dropUp(turtle.getItemCounter())
- assert(loadfile("inv_search"))("minecraft:wheat_seeds")
- turtle.dropUp(turtle.getItemCounter())
- os.sleep(20)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement