View difference between Paste ID: XhzKKeTD and xw45DNzy
SHOW: | | - or go back to the newest paste.
1
local length = 61
2
local width = 61
3
4
local function refuel()
5
	if turtle.getFuelLevel() < 50 then
6
		local prev = turtle.getSelectedSlot()
7
		turtle.select(1)
8
		if not turtle.refuel(4) then
9
			print('Need more fuel')
10
			while not turtle.refuel(4) do
11
				sleep(3)
12
			end
13
		end	
14
		turtle.select(prev)
15
	end
16
end
17
18
local function tryForwards()
19
	refuel()
20
	while not turtle.forward() do
21
		if turtle.detect() then
22
			turtle.dig()
23
			sleep(.5)
24
			while turtle.detect() do
25
				turtle.dig()
26
				sleep(.5)
27
			end
28
		elseif turtle.attack() then
29
		else 
30
			sleep(1)
31
		end
32
	end
33
end
34
35
local function advance()
36
	if turtle.getSelectedSlot() == 16 then
37
		print('Need more materials')
38
		local empty = true
39
		while empty do
40
			for n=2, 16 do
41
                print (n)
42
                if turtle.getItemCount(n) > 0 then
43
                    empty = false
44
                    turtle.select(n)
45
                    return
46
                end
47
            end
48
			sleep(3)
49
		end
50
	else
51
		turtle.select(turtle.getSelectedSlot() + 1)
52
	end
53
end	
54
55
local function placeBlock()
56
	if not turtle.detectDown() then
57
		if not turtle.placeDown() or turtle.getItemCount() == 0 or turtle.getItemDetail().name ~= "minecraft:stone_slab" then 
58
			while turtle.getItemCount() == 0 or turtle.getItemDetail().name ~= "minecraft:stone_slab" do
59
				advance()
60
			end
61
		end
62
	end
63
end
64
local function turnAround(i)
65
	turtle.placeDown()
66
	if i%2 == 1 then
67
		turtle.turnRight()
68
		tryForwards()
69
		turtle.turnRight()
70
	else
71
		turtle.turnLeft()
72
		turtle.forward()
73
		turtle.turnLeft()
74
	end
75
end
76
turtle.select(2)
77-
for i = 1, length, 1 do
77+
for i = 1, length-1, 1 do
78
	for j = 1, width-1, 1 do
79
		refuel()
80
		placeBlock()
81
		placeBlock()
82
		tryForwards()
83
	end
84
	turnAround(i)
85
end