View difference between Paste ID: gMKxXwSP and raWH4UfY
SHOW: | | - or go back to the newest paste.
1
local tArgs = {...}
2
3
if #tArgs < 1 then
4
	print("Rong usage.")
5
	print("Syntax: farmoaks <number of oaks to farm>")
6
	return
7
end
8
9
local iterations = tonumber(tArgs[1])
10
local Hpos = 0
11
local Vpos = 0
12
13
local function plantSapling()
14
	turtle.select(1)
15
	if not turtle.place() then
16
		print("No saplings! Aborting.")
17
		return
18
	end
19
end
20
21
local function applyBoneMeal()
22
	turtle.select(1) -- Sapling
23
	
24
	while turtle.compare(1) do
25
		turtle.select(2) -- Bone Meal
26
		if not turtle.place() then
27
			print ("No Bone Meal! Aborting.")
28
			return
29
		end
30
		turtle.select(1) -- Sapling
31
	end
32
end
33
34
local function cutTree()
35
36-
	if not turtle.dig() then
36+
	while not turtle.forward() do
37-
		print("Something's Rong! No tree to cut. Aborting")
37+
38
		
39
		if fuel < 1 then
40
			while not turtle.refuel() do
41-
	while not turtle.forward do
41+
42
			end
43
		end
44
		
45
		if not turtle.dig() then
46
			print("Something's Rong! No tree to cut. Aborting")
47
			return
48
		end
49
	end
50
	
51
	-- Hpos = Hpos + 1
52
	turtle.select(3) -- wood
53
	
54
	while turtle.compareUp(3) do
55
		turtle.digUp()
56
		turtle.up()
57
		Vpos = Vpos + 1
58
	end
59
	
60
	while Vpos > 0 do
61
		if not turtle.down() then
62
			print("Tried to go down further and couldn't.")
63
		end
64
		Vpos = Vpos - 1
65
	end
66
	turtle.back()
67
end
68
69
local function returnWood()
70
	turtle.turnLeft()
71
	turtle.turnLeft()
72
	for n=4,16 do
73
		turtle.select(n)
74
		turtle.drop()
75
	end
76
	turtle.turnLeft()
77
	turtle.turnLeft()
78
end
79
80
for i = 1, iterations do
81
	plantSapling()
82
	applyBoneMeal()
83
	cutTree()
84
	returnWood()
85
end