-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree-felling.lua
102 lines (94 loc) · 2.19 KB
/
tree-felling.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
os.loadAPI("./common")
WOOD_SLOT = 1
SAPPLING_SLOT = 2
BONE_SLOT = 3
sX = 0
if arg[1] then sX = tonumber(arg[1]) end
sY = 0
if arg[2] then sY = tonumber(arg[2]) end
sZ = 0
if arg[3] then sZ = tonumber(arg[3]) end
print("Starting zone " .. sX .. ", " .. sY .. ", " .. sZ)
function chopDownTree()
turtle.select(WOOD_SLOT)
common.navigate(sX, sY, sZ)
common.setDirection("north")
if turtle.compare() and turtle.inspect() then
print("Chopping tree")
turtle.dig()
common.forward()
while turtle.compareUp() do
turtle.digUp()
common.up()
turtle.dig()
common.turnLeft()
turtle.dig()
common.turnLeft()
turtle.dig()
common.turnLeft()
turtle.dig()
end
common.navigate(sX,sY,sZ)
common.setDirection("south")
local logs = turtle.getItemCount(WOOD_SLOT) - 1
turtle.drop(logs)
else
print("No tree or no log found")
end
end
function cleanUp()
common.setDirection("west")
turtle.suck()
common.forward()
turtle.suck()
common.turnRight()
turtle.suck()
common.forward()
turtle.suck()
common.forward()
turtle.suck()
common.turnRight()
turtle.suck()
common.forward()
turtle.suck()
common.forward()
turtle.suck()
common.turnRight()
turtle.suck()
common.forward()
turtle.suck()
common.forward()
common.navigate(sX,sY,sZ)
common.setDirection("south")
for i=4,15,1 do
turtle.select(i)
turtle.drop()
end
end
function placeSappling()
common.navigate(sX,sY,sZ)
common.setDirection("north")
turtle.select(SAPPLING_SLOT)
turtle.place()
turtle.select(BONE_SLOT)
local notGrown = turtle.place()
while notGrown do
notGrown = turtle.place()
end
end
function getBoneMeal()
common.navigate(sX-1,sY,sZ)
common.setDirection("south")
turtle.select(BONE_SLOT)
space = turtle.getItemSpace()
turtle.suck(space)
end
-- Begin --
common.gpsInit()
common.navigate(sX, sY, sZ)
common.setDirection("north")
common.reFuel(sX+1, sY, sZ)
chopDownTree()
cleanUp()
getBoneMeal()
placeSappling()