-
Notifications
You must be signed in to change notification settings - Fork 0
/
wood.lua
100 lines (91 loc) · 2.24 KB
/
wood.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
--[[ Programme de bûcheronnage ]]--
function cutting()
turtle.select(1)
-- Attend que l'arbre ait poussé --
local success, data = nil, nil
success, data = turtle.inspect()
while data.name == "minecraft:sapling" do
success, data = turtle.inspect()
end
turtle.dig()
turtle.forward()
-- Coupe l'arbre sur toute sa hauteur, puis redescend --
success, data = turtle.inspectUp()
while data.name == "minecraft:log" do
turtle.digUp()
turtle.up()
success, data = turtle.inspectUp()
end
success, data = turtle.inspectDown()
while not success do
turtle.down()
success, data = turtle.inspectDown()
end
end
function planting()
-- Avance d'un cube, place une pousse d'arbre derrière lui et se repositionne --
turtle.forward()
for i = 1, 2 do
turtle.turnLeft()
end
turtle.select(16)
turtle.place()
for i = 1, 2 do
turtle.turnRight()
end
end
while true do
-- S'équipe en carburant (charbon de bois) --
turtle.select(15)
turtle.turnLeft()
turtle.suck(4)
turtle.refuel()
turtle.turnRight()
-- S'équipe en pousses d'arbre --
turtle.select(16)
suck = turtle.suckDown(8)
-- Coupe le premier arbre, se positionne pour le parcours... --
cutting()
turtle.turnRight()
planting()
-- ...Puis coupe les trois segments d'arbres suivants --
for i = 1, 3 do
for j = 1, 2 do
for k = 1, 2 do
turtle.forward()
end
cutting()
if j == 2 then
turtle.turnRight()
end
planting()
end
end
-- Coupe le dernier segment d'arbres et dépose les bûches dans un coffre --
for k = 1, 2 do
turtle.forward()
end
cutting()
planting()
turtle.turnLeft()
turtle.forward()
for i = 1, 16 do
turtle.select(i)
if turtle.getItemCount() == 0 then
break
end
turtle.dropDown()
end
turtle.select(1)
turtle.suckDown(4)
turtle.back()
turtle.turnRight()
for k = 1, 2 do
turtle.forward()
end
turtle.up()
turtle.turnLeft()
turtle.drop()
turtle.turnRight()
turtle.down()
end