View difference between Paste ID: LScuGfym and 7BGhUwXk
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-
function fuel()
38+
39-
	if turtle.getFuelLevel() <= 10 then
39+
40-
		turtle.select(16)
40+
41-
		turtle.refuel(1)
41+
42-
	print("Fuel less than 10, refueling.")
42+
43
        while r==0 do
44
                turtle.down()
45-
	elseif turtle.getFuelLevel() == "unlimited" then
45+
46-
        print("This turtle does not use fuel to move")
46+
47
                end
48-
        return
48+
49
        turtle.back()
50
end
51
52
--function cutTree()
53
--	sleep(2)
54
55
56
--print("Cutting Tree.")
57-
		fuel()
57+
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-
--	fuel()
69+
70
--end
71
 
72
function cutTree()
73
print("tree cut")
74
hi = 0
75
while not turtle.detectUp() do
76-
--		fuel()
76+
77
end
78
du() up() du() up() du() l() l()
79
c(1) r() c(2) r() c(4) r() c(4) r()
80
c(4) r() c(1) r() c(3) l() c(2) l()
81
c(2) back() l() c(1) l() down()
82
for r=1,hi do dd() down() end
83
dd() back()
84
down() down()
85
print(hi)
86
end
87
88
function checkMats()
89
        -- Checking saplings slot
90
print("Checking for mats.")
91
	sleep(2)
92
        if turtle.getItemCount(1)==0 then
93
	print("Not enough Saplings.")
94
                s=1
95
                turtle.turnLeft()
96
                turtle.select(1)
97
                turtle.suck()
98
                turtle.turnRight()
99
                if turtle.getItemCount(1)>0 then
100
                        s=0
101
                end
102
        end
103
       
104
        -- Checking bonemeal slot
105
        if turtle.getItemCount(2)==0 then
106
	print("Not enough bonemeal.")
107
                turtle.turnLeft()
108
                turtle.turnLeft()
109
                turtle.select(1)
110
                turtle.suck()
111
                turtle.turnRight()
112
                turtle.turnRight()
113
        end
114
115
end
116
117
function checkStop()
118
        if s==0         then
119
                shell.exit()
120
        end
121
end
122
123
function ConsolidateMats()
124
turtle.turnLeft()
125
	print("Consolidating saplings.")
126
for i=3,15 do
127
turtle.select(i)
128
129
if turtle.compareTo(1) then -- It's a sapling not in slot one
130-
        -- Checking fuel slot
130+
131-
        if turtle.getItemCount(16)<=10 then
131+
132-
	print("Not enough Fuel.")
132+
133
turtle.turnRight()
134
135
	print("Sending all other mats to processing.")
136
	sleep(2)
137
for i=3,15 do
138
turtle.select(i)
139
turtle.dropDown()
140
end
141
end
142
143
while true do
144
makeTree()
145
checkMats()
146
cutTree()
147
ConsolidateMats()
148
checkStop()
149
end