Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FARMX = 5
- FARMY = 3
- TREE_DISTANCE_X = 3
- TREE_DISTANCE_Y = 3
- ITER_DELAY = 60
- m=peripheral.find('magnet')
- function checkblock(r,d)
- t = d.tags
- if type(t)~='table' then return false end
- if t["minecraft:logs"] then return true else return false end
- end
- function check_front()
- return checkblock(turtle.inspect())
- end
- function check_up()
- return checkblock(turtle.inspectUp())
- end
- function check_down()
- return checkblock(turtle.inspectDown())
- end
- function dfs_mine()
- for i=1,4 do
- if check_front() then
- turtle.dig()
- turtle.forward()
- dfs_mine()
- turtle.back()
- end
- turtle.turnRight()
- if check_up() then
- turtle.digUp()
- turtle.up()
- dfs_mine()
- turtle.down()
- end
- if check_down() then
- turtle.digDown()
- turtle.down()
- dfs_mine()
- turtle.up()
- end
- end
- end
- function straight_mine()
- i=0
- while check_up() do
- turtle.digUp()
- turtle.up()
- i=i+1
- end
- while i>0 do
- turtle.down()
- i=i-1
- end
- end
- function check_refuel()
- turtle.select(1)
- while turtle.getFuelLevel()<160 do
- turtle.refuel(1)
- end
- end
- mine_tree_func = straight_mine --or dfs_mine
- function handle_farm(x,y)
- turtle.forward()
- for a=1,x do
- for b=1,y do
- for i=1,TREE_DISTANCE_X do
- turtle.forward()
- end
- turtle.turnLeft()
- if check_front() then
- check_refuel()
- turtle.dig()
- turtle.forward()
- mine_tree_func()
- turtle.back()
- check_refuel()
- os.sleep(5)
- m.magnetize(4)
- end
- turtle.select(2)
- turtle.place()
- turtle.select(1)
- turtle.turnRight()
- check_refuel()
- end
- for b=1,y*TREE_DISTANCE_X do turtle.back() end
- turtle.turnRight()
- for i=1,TREE_DISTANCE_Y do
- turtle.forward()
- end
- turtle.turnLeft()
- check_refuel()
- end
- turtle.turnLeft()
- for a=1,TREE_DISTANCE_Y*x do
- turtle.forward()
- check_refuel()
- end
- turtle.turnRight()
- turtle.back()
- turtle.turnLeft()
- turtle.turnLeft()
- check_refuel()
- for i=3,16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- turtle.turnLeft()
- turtle.turnLeft()
- end
- it=1
- while true do
- print("Iteration #"..tostring(it))
- handle_farm(FARMX,FARMY)
- print("Done!")
- os.sleep(ITER_DELAY)
- it=it+1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement