View difference between Paste ID: FEVCQg4g and UTc9HX06
SHOW: | | - or go back to the newest paste.
1
t = turtle
2-
function moveForward()
2+
3
function distanceInput()
4
	print("Input Distance")
5
	num = io.read
6
	num = tonumber(num)
7
	return num
8
end
9
10-
function moveUpward()
10+
function hole(distance)
11-
	if t.detectUp() then
11+
12-
		t.digUp()
12+
		if t.detectDown() then
13
			t.digDown()
14
			t.down()
15
		else
16
			t.down()
17
	distance = distance - 1
18-
function moveDownward()
18+
19-
	if t.detectDown() then
19+
20-
		t.digDown()
20+
function modulo(tile)
21-
		t.down()
21+
	while tile > 8 do
22
		tile = tile - 8
23-
		t.down()
23+
24
	print("Currently at tile: ", tile)
25
	return tile
26-
function fuelTurtle(distance)
26+
27-
	t.refuel((distance/80)+1)
27+
function turn(num)
28
	while num > 0 do
29-
function moveDistanceForward(distance)
29+
		t.turnRight()
30
		num = num - 1
31-
		moveForward()
31+
32
end
33
function turnAround()
34
	t.turnLeft()
35-
function moveDistanceUpward(distance)
35+
36
end
37-
		moveUpward()
37+
function dleft()
38
	t.turnLeft()
39
	if t.detect() then
40
		t.dig()
41-
function moveDistanceDownward(distance)
41+
42
	else
43-
		moveDownward()
43+
44
	end
45
	t.turnRight()
46
end
47
function dright()
48-
  print("Input distance: ")
48+
	t.turnRight()
49-
  num = io.read()
49+
50-
  num = tonumber(num)
50+
51-
  return num
51+
52
	else
53
		t.forward()
54
	end
55
	t.turnLeft()
56
end
57-
function moveUp()
57+
function dback()
58-
	if t.detectUp() then
58+
59-
		t.digUp()
59+
60
		t.dig()
61
		t.forward()
62
	else
63
		t.forward()
64
	end
65-
---------------
65+
66-
function shaft()
66+
67
function bforward()
68-
	fuelTurtle(distance*2)
68+
69-
	moveDistanceForward(distance)
69+
70-
	moveUp()
70+
71
	else
72-
	moveDistanceForward(distance)
72+
73
	end
74
end
75-
function hole()
75+
function mineLayer(module)
76
	if module == 2 or module == 4 or module == 6 or module == 8 then
77-
	print("Return? 0 = no, 1 = yes")
77+
		turn(module/2)
78-
	yon = tonumber(io.read())
78+
		dleft()
79-
	fuelTurtle(distance)
79+
		dforward()
80-
	moveDistanceDownward(distance)
80+
		dback()
81-
	fuelTurtle(distance)
81+
		dback()
82-
	if not yon == 0 then
82+
		dright()
83-
		moveDistanceUpward(distance)
83+
		dright()
84
		dforward()
85
		dforward()
86-
--------------
86+
		dback()
87-
function main()
87+
		dleft()
88-
	print("1 = Shaft, 2 = Hole")
88+
89-
	func = io.read()
89+
		turn((module+1)/2)
90-
	func = tonumber(func)
90+
		dforward()
91-
	if func == 1 then
91+
		dright()
92-
		shaft()
92+
		dback()
93-
	elif func == 2 then
93+
		dback()
94-
		hole()
94+
		dleft()
95
		dleft()
96-
		print("Please input a valid function")
96+
		dforward()
97
		dright()
98
	end
99
end
100-
main()
100+
function mine(distance)
101
	module = 0
102
	while distance > 0 do
103
		module = modulo(distance)
104
		mineLayer(module)
105
		t.up()
106
		distance = distance - 1
107
	end
108
end
109
function spiral()
110
	distance = distanceInput()
111
	print("3x3 Spiral Initiated; No further input required")
112
	hole(distance)
113
	mine(distance)
114
end