View difference between Paste ID: AtR0aCfF and hKLb71cB
SHOW: | | - or go back to the newest paste.
1
local function checkFuel()
2
  if turtle.getFuelLevel() < 1 then
3
    turtle.select(2)
4
    turtle.refuel(1)
5
  end
6
end
7
-- 
8
local function Saplings()
9-
  Saplings = tonumber(turtle.getItemCount(1))
9+
  if turtle.getItemCount(1) > 3 then
10-
  if Saplings > 3 then
10+
11
  else
12
    print "Need at least 4 saplings in Slot 1"
13
      while turtle.getItemCount(1) < 4 do
14-
      while Saplings < 4 do
14+
15-
        Saplings = tonumber(turtle.getItemCount(1))
15+
16
  end
17
end
18
--
19
local function Start()
20
  turtle.dig()
21
  checkFuel()
22
  turtle.forward()
23
end
24
--
25
local function FellUp()
26
up = 0
27
  while turtle.detectUp() do
28
    turtle.digUp()
29
    turtle.dig()
30
    checkFuel()
31
    turtle.up()
32
    up = up + 1
33
  end
34
end
35
--
36
local function Move()
37
  turtle.dig()
38
  checkFuel()
39
  turtle.turnRight()
40
  turtle.dig()
41
  turtle.forward()
42
  turtle.turnLeft()
43
end
44
--
45
local function FellDown()
46
  while up > 0 do
47
    turtle.dig()
48
    turtle.digDown()
49
    checkFuel()
50
    turtle.down()
51
    up = up - 1
52
  end
53
end
54
--
55
local function Plant() --That's a mess. Sorry :)
56
  turtle.dig()
57
  checkFuel()
58
  turtle.up()
59
  turtle.select(1)
60
  turtle.placeDown()
61
  checkFuel()
62
  turtle.forward()
63
  turtle.select(1)
64
  turtle.placeDown()
65
  turtle.turnLeft()
66
  checkFuel()
67
  turtle.forward()
68
  turtle.select(1)
69
  turtle.placeDown()
70
  turtle.turnLeft()
71
  checkFuel()
72
  turtle.forward()
73
  turtle.select(1)
74
  turtle.placeDown()
75
  checkFuel()
76
  turtle.forward()
77
  checkFuel()
78
  turtle.turnRight()
79
  turtle.down()
80
end
81
--
82
local function Drop()
83
    for i = 2,16 do
84
        turtle.select(i)
85
        turtle.drop()
86
    end
87
end
88
-- Begin
89
local function CheckTree()
90
  turtle.select(1)
91
  if turtle.compare() then
92
    Check = 0
93
  else
94
    Check = 1
95
  end
96
end
97
--
98
local function Chop() -- Main function
99
  while Check == 1 do
100
    term.clear() term.setCursorPos(1,1) term.write("Tree detected...Chopping")
101
    Start()
102
    FellUp()
103-
    Saplings()
103+
104
    FellDown()
105
    Plant()
106
    Drop()
107
    turtle.turnRight()
108
    Check = 0
109
  end
110
end
111
-- 
112
while true do
113
  Saplings()
114
  CheckTree()
115
  Chop()
116
  sleep(1)
117
  if Check == 0 then
118
    term.clear()
119
    term.setCursorPos(1,1)
120
    term.write("Waiting for Tree")
121
  end
122
end