View difference between Paste ID: Nkfk7hae and GMq6qaP8
SHOW: | | - or go back to the newest paste.
1
function f(loc)
2
 while not turtle[loc]() do
3
  sleep(0.5)
4
 end
5
end
6
function up() f("up") end
7
function down() f("down") end
8
function fw() f("forward") end
9
function back() f("back") end
10
function l() f("turnLeft") end
11
function r() f("turnRight") end
12
function d() turtle.dig() end
13
function du() turtle.digUp() end
14
function dd() turtle.digDown() end
15
function c(x)
16
for i=1,x do d() fw() du() dd() end
17
end
18
19
function makeTree()
20
        if turtle.getItemCount(1)==0 then
21
	print("Not enough Saplings.")
22
	return
23
	end
24
25
        if turtle.getItemCount(2)==0 then
26
	print("Not enough BoneMeal.")
27
	return
28
	end
29
turtle.select(1)
30
turtle.place()
31
sleep(1)
32
turtle.select(2)
33
turtle.place()
34
sleep(1)
35
end
36
37
38
39
function resetPos()
40
print("Resetting position.")
41
	sleep(2)
42
        r=0
43
        while r==0 do
44
                turtle.down()
45
                if turtle.detectDown()==true then
46
                        r=1
47
                end
48
        end
49
        turtle.back()
50
end
51
52
--function cutTree()
53
--	sleep(2)
54
55
56
--print("Cutting Tree.")
57
--	sleep(2)
58
--        turtle.dig()
59
--        turtle.forward()
60
--        y=1
61
--        while y==1 do
62
--                turtle.digUp()
63
--                turtle.up()
64
--                if turtle.detectUp()==false then
65
--                        y=0
66
--                end
67
--       end
68
--
69
--resetPos()
70
--end
71
 
72
function cutTree()
73
print("tree cut")
74
hi = 0
75
while not turtle.detectUp() do
76
up() hi=hi+1
77
print("cut loop")
78
print(hi)
79
end
80
du() up() du() up() du() l() l()
81
c(1) r() c(2) r() c(4) r() c(4) r()
82
c(4) r() c(1) r() c(3) l() c(2) l()
83
c(2) back() l() c(1) l() down()
84
for r=1,hi do dd() down() end
85
dd() back()
86
down() 
87
print(hi)
88
end
89
90
function checkMats()
91
        -- Checking saplings slot
92
print("Checking for mats.")
93
	sleep(2)
94
        if turtle.getItemCount(1)==0 then
95
	print("Not enough Saplings.")
96
                s=1
97
                turtle.turnLeft()
98
                turtle.select(1)
99
                turtle.suck()
100
                turtle.turnRight()
101
                if turtle.getItemCount(1)>0 then
102
                        s=0
103
                end
104
        end
105
       
106
        -- Checking bonemeal slot
107
        if turtle.getItemCount(2)==0 then
108
	print("Not enough bonemeal.")
109
                turtle.turnLeft()
110
                turtle.turnLeft()
111
                turtle.select(1)
112
                turtle.suck()
113
                turtle.turnRight()
114
                turtle.turnRight()
115
        end
116
117
end
118
119
function checkStop()
120
        if s==0         then
121
                shell.exit()
122
        end
123
end
124
125
function ConsolidateMats()
126
turtle.turnLeft()
127
	print("Consolidating saplings.")
128
for i=3,15 do
129
turtle.select(i)
130
131
if turtle.compareTo(1) then -- It's a sapling not in slot one
132
turtle.drop() -- put it in the chest to our left
133
end
134
end
135
turtle.turnRight()
136
137
	print("Sending all other mats to processing.")
138
	sleep(2)
139
for i=3,15 do
140
turtle.select(i)
141
turtle.dropDown()
142
end
143
end
144
145
while true do
146
makeTree()
147
checkMats()
148
cutTree()
149
ConsolidateMats()
150
checkStop()
151
end