SHOW:
|
|
- or go back to the newest paste.
1 | - | local enderchest = false |
1 | + | local enderches = true |
2 | local torch = turtle.getItemCount(1) | |
3 | local chests = turtle.getItemCount(2) | |
4 | local dist = 0 | |
5 | ||
6 | function dump() | |
7 | if turtle.getItemCount(16)>0 then | |
8 | turtle.digDown() | |
9 | turtle.select(2) | |
10 | turtle.placeDown() | |
11 | for slot = 3,16,1 do | |
12 | turtle.select(slot) | |
13 | turtle.dropDown() | |
14 | end | |
15 | if enderchest then | |
16 | turtle.select(2) | |
17 | turtle.digDown() | |
18 | else | |
19 | - | local c = c - 1 |
19 | + | local chests = chests - 1 |
20 | end | |
21 | end | |
22 | end | |
23 | ||
24 | function digforw() | |
25 | if turtle.detect() then | |
26 | turtle.dig() | |
27 | end | |
28 | turtle.forward() | |
29 | dump() | |
30 | turtle.digUp() | |
31 | dump() | |
32 | dist = dist + 1 | |
33 | end | |
34 | ||
35 | function home() | |
36 | turtle.turnLeft() | |
37 | turtle.turnLeft() | |
38 | if turtle.detectUp() then | |
39 | turtle.digUp() | |
40 | end | |
41 | turtle.up() | |
42 | for i=1,dist,1 do | |
43 | turtle.forward() | |
44 | end | |
45 | turtle.down() | |
46 | if torch==0 then | |
47 | print("Ran out of torches.") | |
48 | elseif chests==0 then | |
49 | print("Ran out of chests.") | |
50 | else | |
51 | print("Ran out of fuel.") | |
52 | end | |
53 | turtle.turnLeft() | |
54 | turtle.turnLeft() | |
55 | end | |
56 | ||
57 | function light() | |
58 | turtle.turnLeft() | |
59 | turtle.turnLeft() | |
60 | turtle.select(1) | |
61 | turtle.place() | |
62 | turtle.turnLeft() | |
63 | turtle.turnLeft() | |
64 | torch = torch - 1 | |
65 | end | |
66 | ||
67 | local retdist = 0 | |
68 | local fuel = turtle.getFuelLevel() | |
69 | function run() | |
70 | while (torch>0) and (chests>0) and (fuel>retdist) do | |
71 | for i=1,12,1 do | |
72 | digforw() | |
73 | end | |
74 | light() | |
75 | retdist = dist + 14 | |
76 | fuel = turtle.getFuelLevel() | |
77 | end | |
78 | home() | |
79 | end | |
80 | ||
81 | run() |