Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --farmer turtle
- function isEmpty()
- for i = 1,16 do
- if ( turtle.getItemCount(i) > 0 ) then
- return false
- end
- end
- return true
- end
- function refuel()
- if ( turtle.getFuelLevel() < 5000 ) then
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then -- if it's valid fuel
- turtle.refuel()
- end
- end
- end
- end
- function unload()
- for i = 1,16 do
- turtle.select(i)
- turtle.dropDown()
- end
- end
- function uturn()
- turtle.turnRight()
- turtle.turnRight()
- end
- function f(dist)
- print("[going forward] blocs left : "..dist)
- if ( dist > 1) then
- if ( turtle.detect() ) then
- turtle.dig()
- end
- turtle.forward()
- f(dist-1)
- end
- end
- function u(dist)
- print("[going up] blocs left : "..dist)
- if ( dist > 1) then
- if ( turtle.detectUp() ) then
- turtle.digUp()
- end
- turtle.up()
- u(dist-1)
- end
- end
- function d(dist)
- print("[going down] blocs left : "..dist)
- if ( dist > 1) then
- if ( turtle.detectDown() ) then
- turtle.digDown()
- end
- turtle.down()
- d(dist-1)
- end
- end
- function farmPumpkin(nb)
- --going through a row of pumpkin
- f(nb)
- --get back to starting point
- uturn()
- f(nb)
- --resetting position for next run
- uturn()
- --unload turtle inv in a chest below
- unload()
- end
- function farmMelon(nb)
- --same thing as farm Pumpkin, we call the method
- farmPumpkin(nb)
- end
- function farmSugarCanes(nb)
- --y+2 : farming top layer
- u(2)
- f(nb)
- --y+1 : farming middle layer as we get back to the starting point
- uturn()
- d(1)
- f(nb)
- --resetting position for next run
- uturn()
- d(1)
- --unload turtle inv in a chest below
- unload()
- end
- function farmGrassField
- end
- if ( isEmpty() ) then
- while true do
- -- farm function call
- sleep(10)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement