SHOW:
|
|
- or go back to the newest paste.
1 | local tArgs = { ... } | |
2 | if #tArgs ~= 1 then | |
3 | print("Usage: Hoehe <high>") | |
4 | return | |
5 | end | |
6 | ||
7 | -- Mine in a quarry pattern until we hit something we can`t dig | |
8 | - | local high = tonumber( tArgs[1] ) -13 |
8 | + | local high = tonumber( tArgs[1] ) |
9 | if high < 1 then | |
10 | print("Treppen hoehe must be positive") | |
11 | return | |
12 | end | |
13 | ||
14 | local depth = high | |
15 | local collected = 0 | |
16 | local ll = 0 | |
17 | ||
18 | print("Treppen in Fach 15 legen") | |
19 | print("Fackeln in Fach 14 legen") | |
20 | print("Steine in Fach 1 legen") | |
21 | print("Schritte bis Ebene 12 = ",high) | |
22 | print() | |
23 | print(" In 10 Sec geht es los") | |
24 | sleep(10) | |
25 | ||
26 | local function collect() | |
27 | collected = collected +1 | |
28 | if math.fmod(collected, 25) == 0 then | |
29 | print("Mined "..collected.." items.") | |
30 | end | |
31 | end | |
32 | ||
33 | local function tryDig() | |
34 | while turtle.detect() do | |
35 | if turtle.dig() then | |
36 | collect() | |
37 | sleep(0.5) | |
38 | else | |
39 | return false | |
40 | end | |
41 | end | |
42 | return true | |
43 | end | |
44 | ||
45 | local function tryDigDown() | |
46 | while turtle.detectDown() do | |
47 | if turtle.digDown() then | |
48 | collect() | |
49 | sleep(0.5) | |
50 | else | |
51 | return false | |
52 | end | |
53 | end | |
54 | return true | |
55 | end | |
56 | ||
57 | local function tryDigUp() | |
58 | while turtle.detectUp() do | |
59 | if turtle.digUp() then | |
60 | collect() | |
61 | sleep(0.5) | |
62 | else | |
63 | return false | |
64 | end | |
65 | end | |
66 | return true | |
67 | end | |
68 | ||
69 | local function refuel() | |
70 | local fuelLevel = turtle.getFuelLevel() | |
71 | if fuelLevel == "unlimited" or fuelLevel > 0 then | |
72 | return | |
73 | end | |
74 | ||
75 | local function tryRefuel() | |
76 | for n=1,16 do | |
77 | if turtle.getItemCount(n) > 0 then | |
78 | turtle.select(n) | |
79 | if turtle.refuel(1) then | |
80 | turtle.select(1) | |
81 | return true | |
82 | end | |
83 | end | |
84 | end | |
85 | turtle.select(1) | |
86 | return false | |
87 | end | |
88 | ||
89 | if not tryRefuel() then | |
90 | print( "Add more fuel to continue." ) | |
91 | while not tryRefuel() do | |
92 | sleep(1) | |
93 | end | |
94 | print( "Resuming Tunnel." ) | |
95 | end | |
96 | end | |
97 | ||
98 | local function tryUp() | |
99 | refuel() | |
100 | while not turtle.up() do | |
101 | if turtle.detectUp() then | |
102 | if not tryDigUp() then | |
103 | return false | |
104 | end | |
105 | elseif turtle.attackUp() then | |
106 | collect() | |
107 | else | |
108 | sleep( 0.5 ) | |
109 | end | |
110 | end | |
111 | return true | |
112 | end | |
113 | ||
114 | local function tryDown() | |
115 | refuel() | |
116 | while not turtle.down() do | |
117 | if turtle.detectDown() then | |
118 | if not tryDigDown() then | |
119 | return false | |
120 | end | |
121 | elseif turtle.attackDown() then | |
122 | collect() | |
123 | else | |
124 | sleep( 0.5 ) | |
125 | end | |
126 | end | |
127 | return true | |
128 | end | |
129 | ||
130 | local function tryForward() | |
131 | refuel() | |
132 | while not turtle.forward() do | |
133 | if turtle.detect() then | |
134 | if not tryDig() then | |
135 | return false | |
136 | end | |
137 | elseif turtle.attack() then | |
138 | collect() | |
139 | else | |
140 | sleep( 0.5 ) | |
141 | end | |
142 | end | |
143 | return true | |
144 | end | |
145 | ||
146 | print( "Baue die Treppe...") | |
147 | ||
148 | tryDig() | |
149 | tryForward() | |
150 | ll=0 | |
151 | ||
152 | - | tryDigUp() |
152 | + | |
153 | - | tryUp() |
153 | + | tryForward() |
154 | - | tryDigUp() |
154 | + | tryUp() |
155 | - | tryUp() |
155 | + | tryUp() |
156 | - | tryDigUp() |
156 | + | tryUp() |
157 | - | tryDown() |
157 | + | tryDown() |
158 | - | tryDown() |
158 | + | tryDown() |
159 | - | tryDigDown() |
159 | + | ll = ll +1 |
160 | - | tryDown() |
160 | + | if ll == 5 then |
161 | - | if turtle.detectDown() == false then |
161 | + | turtle.turnRight() |
162 | - | turtle.select(1) |
162 | + | tryDig() |
163 | - | turtle.placeDown() |
163 | + | turtle.select(14) |
164 | turtle.place() | |
165 | turtle.turnRight() | |
166 | - | if n<high then |
166 | + | turtle.turnRight() |
167 | - | tryDig() |
167 | + | tryDig() |
168 | - | if not tryForward() then |
168 | + | turtle.place() |
169 | - | print( "Aborting Tunnel." ) |
169 | + | turtle.turnRight() |
170 | - | break |
170 | + | ll = 0 |
171 | end | |
172 | end | |
173 | - | print( "Tunnel complete." ) |
173 | + | if n<high then |
174 | tryDig() | |
175 | if not tryForward() then | |
176 | print( "Aborting Tunnel." ) | |
177 | - | print( "Returning to start..." ) |
177 | + | |
178 | else | |
179 | - | -- Return to where we started |
179 | + | print( "Tunnel complete." ) |
180 | end | |
181 | ||
182 | - | tryDigUp() |
182 | + |