-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtreefarm.lua
82 lines (71 loc) · 1.97 KB
/
treefarm.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
--[[
Builds and chops down a 7x7x? compact tree farm
--]]
os.loadAPI('t')
args = {...}
chop = true
if args[1] == 'build' then
chop = false
end
if t.selectItem('minecraft:chest') then
t.placeDown()
end
-- todo: pick up saplings before chopping
t.forward()
for z = 1, 5 do
for x = 1, 7 do
for y = 1, 7 do
if z == 1 then
local success, block = turtle.inspectDown()
-- if there is a block below and it's not a torch
if success and block.name ~= 'minecraft:torch' and block.name ~= 'minecraft:oak_sapling' then
t.digDown()
if t.selectItem('minecraft:oak_sapling') then
t.placeDown()
end
-- else if there is empty space below
elseif not success then
if t.selectItem('minecraft:oak_sapling') then
t.placeDown()
end
end
end
-- last row
if y == 7 then
-- not last column
if x ~= 7 then
if x % 2 == 0 then
turtle.turnLeft()
t.forward()
turtle.turnLeft()
else
turtle.turnRight()
t.forward()
turtle.turnRight()
end
-- last column
elseif x == 7 and z ~= 5 then
t.up()
t.turnAround()
end
else
t.forward()
end
end
end
end
turtle.turnLeft()
t.forward(6)
turtle.turnLeft()
t.forward(7)
while not turtle.detectDown() do
turtle.down()
end
t.turnAround()
local success, block = turtle.inspectDown()
if success and block.name == 'minecraft:chest' then
for i = 1, 16 do
turtle.select(i)
turtle.dropDown()
end
end