SHOW:
|
|
- or go back to the newest paste.
1 | term.clear() | |
2 | term.setCursorPos(1,1) | |
3 | ||
4 | repeat | |
5 | print("Enter tunnel Length (even number): ") | |
6 | length = read() | |
7 | print("Enter height (even number): ") | |
8 | height = read() | |
9 | print("Enter Width (even number): ") | |
10 | width = read() | |
11 | until length % 2 == 0 | |
12 | term.clear() | |
13 | while turtle.getItemCount(1) == 0 do | |
14 | - | print("Place fuel in slot 1.") |
14 | + | print("Place fuel in slot 1.") |
15 | - | read() |
15 | + | read() |
16 | end | |
17 | while turtle.getItemCount(2) == 0 do | |
18 | - | print("Place torches in slot 2.") |
18 | + | print("Place torches in slot 2.") |
19 | - | read() |
19 | + | read() |
20 | end | |
21 | ||
22 | print("Place chest behind turtle.\n") | |
23 | ||
24 | term.clear() | |
25 | print("Here we go!") | |
26 | torchpos = 0 | |
27 | ||
28 | ||
29 | function fuel() | |
30 | if turtle.getFuelLevel() < 0.26 then | |
31 | turtle.select(1) | |
32 | turtle.refuel(1) | |
33 | end | |
34 | end | |
35 | ||
36 | function mine() | |
37 | local LoopHeight = 0 | |
38 | local LoopWidth = 0 | |
39 | local LoopLength = 0 | |
40 | ||
41 | fuel() | |
42 | --odd numbers left even numbers right | |
43 | for LoopLength = 0, length - 1 do | |
44 | for LoopHeight = 0, height - 1 do | |
45 | if LoopHeight % 2 == 0 then | |
46 | turtle.turnLeft() | |
47 | - | for LoopWidth = 0, width -1 do |
47 | + | if LoopLength > 1 then |
48 | print("LoopLength: ", LoopLength) | |
49 | - | print("LoopWidthL: ", LoopWidth) |
49 | + | print("LoopHeight: ", LoopHeight) |
50 | print("Width: ", width) | |
51 | - | if LoopHeight == height - 1 then |
51 | + | read() |
52 | - | endHeightCheck(LoopWidth) |
52 | + | |
53 | - | end |
53 | + | |
54 | for LoopWidth = 0, width -2 do | |
55 | leftDown() | |
56 | --print("LoopWidthL: ", LoopWidth) | |
57 | - | for LoopWidth = 0, width -1 do |
57 | + | |
58 | if LoopHeight == height - 1 then | |
59 | - | print("LoopWidthR: ", LoopWidth) |
59 | + | endHeightCheck(LoopWidth, LoopLength) |
60 | end | |
61 | - | if LoopHeight == height - 1 then |
61 | + | |
62 | - | endHeightCheck(LoopWidth) |
62 | + | |
63 | - | end |
63 | + | |
64 | - | |
64 | + | for LoopWidth = 0, width -2 do |
65 | rightDown() | |
66 | --print("LoopWidthR: ", LoopWidth) | |
67 | - | if LoopHeight ~= height - 1 then |
67 | + | |
68 | - | checkEmptyDown() |
68 | + | if LoopHeight == height - 1 then |
69 | - | end |
69 | + | endHeightCheck(LoopWidth, LoopLength) |
70 | end | |
71 | turtle.turnLeft() | |
72 | end | |
73 | if LoopHeight ~= height - 1 then | |
74 | if LoopLength % 2 == 0 then | |
75 | checkEmptyDown() | |
76 | else | |
77 | checkEmptyUp() | |
78 | end | |
79 | end | |
80 | end | |
81 | if LoopLength % 2 == 0 then | |
82 | turtle.turnRight() | |
83 | print("Length check Right: ") | |
84 | read() | |
85 | else | |
86 | turtle.turnLeft() | |
87 | print("Length check left: ") | |
88 | read() | |
89 | end | |
90 | ||
91 | end | |
92 | end | |
93 | ||
94 | ||
95 | function checkEmptySpace() | |
96 | while turtle.detect() == true do | |
97 | - | if turtle.detectDown() == true then |
97 | + | |
98 | - | turtle.digDown() |
98 | + | |
99 | end | |
100 | ||
101 | function leftDown() | |
102 | - | |
102 | + | |
103 | - | function endHeightCheck(LoopWidth) |
103 | + | |
104 | - | if LoopWidth % 2 == 1 then |
104 | + | |
105 | - | print("R") |
105 | + | |
106 | - | turtle.turnRight() |
106 | + | |
107 | - | checkEmptySpace() |
107 | + | |
108 | - | turtle.forward() |
108 | + | |
109 | - | print("0: ") |
109 | + | |
110 | function checkEmptyDown() | |
111 | if turtle.detectDown() == true then | |
112 | - | print("L") |
112 | + | turtle.digDown() |
113 | - | turtle.turnLeft() |
113 | + | |
114 | - | checkEmptySpace() |
114 | + | |
115 | - | turtle.forward() |
115 | + | |
116 | - | print("1: ") |
116 | + | |
117 | function checkEmptyUp() | |
118 | - | end |
118 | + | if turtle.detectUp() == true then |
119 | turtle.digUp() | |
120 | end | |
121 | turtle.up() | |
122 | end | |
123 | ||
124 | function endHeightCheck(LoopWidth, LoopLength) | |
125 | if LoopLength % 2 == 0 then | |
126 | if LoopWidth % 2 == 1 then | |
127 | turtle.turnRight() | |
128 | checkEmptySpace() | |
129 | turtle.forward() | |
130 | else | |
131 | turtle.turnLeft() | |
132 | checkEmptySpace() | |
133 | turtle.forward() | |
134 | end | |
135 | else | |
136 | if LoopWidth % 2 == 0 then | |
137 | turtle.turnRight() | |
138 | checkEmptySpace() | |
139 | turtle.forward() | |
140 | else | |
141 | turtle.turnLeft() | |
142 | checkEmptySpace() | |
143 | turtle.forward() | |
144 | end | |
145 | end | |
146 | end | |
147 | mine() |