View difference between Paste ID: 6iqrQizj and VUdJgymy
SHOW: | | - or go back to the newest paste.
1-
path = 16
1+
path = 31
2
direction = 0
3
_sleep = 70-path
4
5
function plant()
6-
  if (turtle.getItemCount() <= 10) then
6+
7-
    for z = 3,16 do
7+
  sapling = {}
8-
      turtle.select(z)
8+
  sapling, sapling.count = turtle.getItemDetail(1)
9-
      turtle.transferTo(1)
9+
 
10
  if (sapling.count <= 1) then
11
    for i = 3,16 do
12
      if (turtle.getItemDetail(i)) then
13
        if (turtle.getItemDetail(i).name == sapling.name) then
14
          turtle.select(i)
15
          turtle.transferTo(1)
16
          plant()
17
          break
18
        end
19
      end
20
    end
21
  elseif (turtle.detect() == false) then
22
    turtle.place()
23
  end
24
end
25
26
function detect()
27
  turtle.select(2)
28
  if (turtle.compare()) then
29
    felling()
30
  else
31
    plant()
32
  end
33
end
34
35
function felling()
36-
  goDown()
36+
37-
  turtle.back()  
37+
38
  while (turtle.detectUp()) do
39
    turtle.digUp()
40
    turtle.up()
41-
  while (turtle.down()) do
41+
42
      turtle.dig()
43
      turtle.turnRight()
44
    end
45
  end
46-
    if (type.name ~= "minecraft:dirt") then
46+
  goDown() 
47
end
48
49
function goDown()
50
  turtle.back()
51
  while turtle.down() do
52
    for i = 1,4 do
53
      turtle.dig()
54
      turtle.turnRight()
55
    end
56
  end
57
  
58
  if (turtle.inspectDown()) then
59
    local block, type = turtle.inspectDown()
60
    if (type.name ~= "minecraft:dirt" and type.name ~= "minecraft:grass_block" and type.name ~= "minecraft:chest") then
61
      turtle.digDown()
62
      goDown()
63
    end
64
  end
65
end
66
67
function pathing()
68
  for x = 2,path do
69
    detect()
70
    
71
    if (direction == 1) then
72
      turtle.turnRight()
73
      turtle.suck()
74
      turtle.forward()
75
      turtle.turnLeft()
76
    else
77
      turtle.turnLeft()
78
      turtle.suck()
79
      turtle.forward()
80
      turtle.turnRight()
81
    end
82
    
83
    detect()
84
  end
85
  
86
  if (direction == 1) then
87
    direction = 0
88
    bank()
89
  else
90
    direction = 1
91
  end
92
end
93
94
function bank()
95-
     sleep(60)
95+
96
    turtle.select(z)
97
    turtle.transferTo(1)
98
    if (turtle.dropDown() == false and turtle.getItemCount() > 0) then
99
      while (true) do
100
        turtle.turnRight()
101
      end
102
    end
103
  end
104
end
105
  
106
function main()
107
   while (true) do
108
     pathing()
109
     sleep(_sleep)
110
   end
111
end
112
113
main()