SHOW:
|
|
- or go back to the newest paste.
1 | - | os.loadAPI("turtleForward.lua") |
1 | + | |
2 | ||
3 | -- Get the dimensions | |
4 | function input(newWidth, newLength, newDepth) | |
5 | width = newWidth | |
6 | length = newLength | |
7 | - | width = newWidth |
7 | + | |
8 | - | length = newLength |
8 | + | fuelcost = 0 |
9 | - | depth = newDepth |
9 | + | |
10 | - | fuelcost = 0 |
10 | + | |
11 | function getFuelCost() | |
12 | return fuelcost | |
13 | - | function setDepth(newDepth) |
13 | + | |
14 | ||
15 | -- Function to Mine to Depth | |
16 | function mineDepth() | |
17 | for i = 1, depth do | |
18 | fuelcost = fuelcost + 1 | |
19 | end | |
20 | - | turtle.digDown() |
20 | + | for j = 1, depth do |
21 | - | turtle.down() |
21 | + | fuelcost = fuelcost + 1 |
22 | end | |
23 | end | |
24 | ||
25 | - | function mineHeight() |
25 | + | |
26 | - | for j = 1, depth do |
26 | + | |
27 | - | turtle.digUp() |
27 | + | |
28 | - | turtle.up() |
28 | + | |
29 | - | end |
29 | + | mineDepth() |
30 | fuelcost = fuelcost + 1 | |
31 | end | |
32 | if i < length then | |
33 | if i % 2 == 1 then | |
34 | - | down = true |
34 | + | mineDepth() |
35 | fuelcost = fuelcost + 1 | |
36 | else | |
37 | - | if down then |
37 | + | mineDepth() |
38 | - | mineDepth() |
38 | + | fuelcost = fuelcost + 1 |
39 | - | down = false |
39 | + | |
40 | - | else |
40 | + | |
41 | - | mineHeight() |
41 | + | |
42 | - | down = true |
42 | + | |
43 | - | end |
43 | + | |
44 | - | turtleForward.moveForward() |
44 | + | |
45 | function toStart() | |
46 | if length % 2 == 1 then | |
47 | for i = 1, width do | |
48 | - | if down then |
48 | + | fuelcost = fuelcost + 1 |
49 | - | mineDepth() |
49 | + | |
50 | - | down = false |
50 | + | |
51 | - | else |
51 | + | |
52 | - | mineHeight() |
52 | + | fuelcost = fuelcost + 1 |
53 | - | down = true |
53 | + | |
54 | - | end |
54 | + | fuelcost = fuelcost + 1 |
55 | - | turtle.turnRight() |
55 | + | |
56 | - | turtleForward.moveForward() |
56 | + | |
57 | - | turtle.turnRight() |
57 | + | |
58 | function predict(newWidth, newLength, newDepth) | |
59 | - | if down then |
59 | + | input(newWidth, newLength, newDepth) |
60 | - | mineDepth() |
60 | + | fuelcost = fuelcost + 1 |
61 | - | down = false |
61 | + | mine(width, length) |
62 | - | else |
62 | + | mineDepth() |
63 | - | mineHeight() |
63 | + | toStart() |
64 | - | down = true |
64 | + | return fuelcost |
65 | - | end |
65 | + |