This repository was archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdig
More file actions
107 lines (103 loc) · 2.9 KB
/
Copy pathdig
File metadata and controls
107 lines (103 loc) · 2.9 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
-- dig out an area starting from the bottom left
os.loadAPI("location")
os.loadAPI("pack")
local maxHeight
local maxWidth
local maxDepth
function init()
print("Dig x: ")
maxDepth = tonumber(io.read())
print("Dig y: ")
maxHeight = tonumber(io.read())
print("Dig z: ")
maxWidth = tonumber(io.read())
-- print("Where is the store?")
-- print("x: ")
-- local x = tonumber(io.read())
-- print("y: ")
-- local y = tonumber(io.read())
-- print("z: ")
-- local z = tonumber(io.read())
-- print("orientation (n,s,e,w): ")
-- oStr = io.read()
-- local o = location.getOrientationFromStr(oStr)
-- location.place["store"] = {x=x,y=y,z=z,o=o}
end
function dig()
print("Here we go!")
local goingUp = true
local home = location.place["home"]
while location.x <= home.x + maxDepth and location.x >= home.x do
--for d=1,maxDepth do
turtle.dig()
turtle.suck()
location.f(1)
local evenRow = false
while location.y <= home.y + maxHeight and location.y >= home.y do
--for h=1,maxHeight do
if evenRow then
--if h % 2 == 0 then
if goingUp then
location.l()
else
location.r()
end
else
if goingUp then
location.r()
else
location.l()
end
end
while location.z <= home.z + maxWidth and location.z >= home.z do
--for w=1,maxWidth-1 do
turtle.dig()
turtle.suck()
if(pack.emptyCount() == 0) then
local here = location.where()
location.goto("store")
pack.dropAll()
location.goto(here)
end
if(location.moves > 5) then
location.goto("home")
end
location.f(1)
location.where()
end
if evenRow then
--if h % 2 == 0 then
if goingUp then
location.r()
else
location.l()
end
else
if goingUp then
location.l()
else
location.r()
end
end
if h == maxHeight then
print("at the top!")
else
if goingUp then
turtle.digUp()
turtle.suckUp()
location.u(1)
else
turtle.digDown()
turtle.suckDown()
location.d(1)
end
end
evenRow = not evenRow
location.where()
end
goingUp = not goingUp
location.where()
end
end
init()
dig()