View difference between Paste ID: kduCfP8s and xw4kzgzv
SHOW: | | - or go back to the newest paste.
1
local args = {...}
2
3
if not #args == 3 then
4
  print("Usage: Args start x,y,z")
5
  return
6
end
7
8-
local spiralSize = 4
8+
local spiralSize = 51
9
local bottom = -58
10
11
local x, y, z = gps.locate(5)
12
13
if not x then
14
	print("co-ord get failed")
15
else
16
	print("start co-ord " .. x .. ", " .. y .. ", " .. z)
17
end
18
19
function returnStart()
20
	local x, y, z = gps.locate(5)
21
	local facing = 0
22
	while not turtle.forward() do turtle.dig() end
23
	local  a,b,c = gps.locate(5)
24
	if x-a == -1 then
25
		facing = 1
26
	elseif z-c == 1 then
27
		facing = 2
28
	elseif x-a == 1 then
29
		facing = 3
30
	else
31
		facing = 0
32
	end
33
	
34
	turtle.turnRight()
35
	turtle.turnRight()
36
	while not turtle.forward() do turtle.dig() end
37
	facing = (facing)%4
38
	print("facing = " .. facing)
39
	turtle.turnRight()
40
	turtle.turnRight()
41
	
42
	for i=0,facing do
43
		turtle.turnRight()
44
	end
45
46
	local xMove = x - args[1]
47
	local zMove = args[3] - z
48
49
	print(xMove)
50
	print(zMove)
51
	
52
	for i=0, xMove-1 do
53
		while not turtle.forward() do turtle.dig() end
54
	end
55
	turtle.turnLeft()
56
	for i=0, zMove-1 do
57
		while not turtle.forward() do turtle.dig() end
58
	end	
59
60
	turtle.turnRight()
61
	turtle.turnRight()
62
end
63
64
function checkInv()
65
  isFull = true
66
  
67
  for i=1,15 do
68
    if turtle.getItemCount(i) == 0 then
69
      isFull = false
70
    end
71
  end
72
  
73
  if isFull == true then
74
	emptyInv()
75
  end
76
end
77
78
function emptyInv()
79
    turtle.select(16)
80
	while turtle.detectUp() do
81
      turtle.digUp()
82
      sleep(0.2)
83
    end
84
	turtle.up()
85
    while not turtle.placeDown() do turtle.digDown() end
86
    for i=1,15 do
87
        turtle.select(i)
88
        turtle.dropDown()
89
    end
90
    turtle.select(16)
91
    turtle.digDown()
92
    sleep(0.1)
93
    turtle.select(1)
94
	turtle.down()
95
end
96
97
function mineLayer()
98
	local spiralCount = spiralSize
99-
		for j=1,4 do
99+
100-
			for k=1,spiralCount do
100+
		for j=1,spiralSize do
101-
				while not turtle.forward() do turtle.dig() end
101+
102-
			end
102+
			while turtle.detectUp() do turtle.digUp() end
103
			while not turtle.forward() do turtle.dig() end
104
		end
105
		if i%2 == 1 then
106-
		spiralCount = spiralCount - 2
106+
107
			while not turtle.forward() do turtle.dig() end
108-
		turtle.forward()
108+
109-
		turtle.turnLeft()
109+
		else
110
			turtle.turnLeft()
111
			while not turtle.forward() do turtle.dig() end
112
			turtle.turnLeft()
113
		end
114-
for l=bottom,args[2] do
114+
115
end
116
		
117
returnStart()
118
for l=bottom,y do
119
	mineLayer()
120
	while turtle.detectDown() do
121
      turtle.digDown()
122
    end
123
	turtle.down()
124
end
125
emptyInv()