SHOW:
|
|
- or go back to the newest paste.
1 | local function mine(x) | |
2 | local counter = 0 | |
3 | repeat | |
4 | turtle.dig() | |
5 | moveForward(1) | |
6 | turtle.digUp() | |
7 | counter = counter + 1 | |
8 | until counter == x | |
9 | end | |
10 | ||
11 | local function turnAround() | |
12 | turtle.turnRight() | |
13 | turtle.turnRight() | |
14 | end | |
15 | ||
16 | function moveForward(x) | |
17 | for i = 1, x, 1 do | |
18 | if turtle.forward() then | |
19 | -- nichts passiert | |
20 | else | |
21 | if turtle.detect() then | |
22 | while(turtle.detect()) do | |
23 | turtle.dig() | |
24 | end | |
25 | moveForward(1) | |
26 | else | |
27 | os.shutdown() | |
28 | end | |
29 | end | |
30 | end | |
31 | end | |
32 | ||
33 | local function placeTorch() | |
34 | turtle.up() | |
35 | turtle.select(2) | |
36 | turtle.back() | |
37 | turtle.place() | |
38 | turtle.down() | |
39 | end | |
40 | ||
41 | - | local function stripMine(x) |
41 | + | local function stripMine(x, placeTorches) |
42 | for i = 1, x, 1 do | |
43 | mine(3) | |
44 | - | if i % 2 == 1 then |
44 | + | if i % 2 == 1 and placeTorches then |
45 | turtle.back() | |
46 | placeTorch() | |
47 | moveForward(2) | |
48 | end | |
49 | ||
50 | turtle.turnRight() | |
51 | mine(8) | |
52 | - | placeTorch() |
52 | + | if placeTorches then |
53 | placeTorch() | |
54 | else | |
55 | turtle.back() | |
56 | - | placeTorch() |
56 | + | |
57 | ||
58 | turnAround() | |
59 | moveForward(7) | |
60 | mine(8) | |
61 | if placeTorches then | |
62 | placeTorch() | |
63 | else | |
64 | turtle.back() | |
65 | end | |
66 | ||
67 | turnAround() | |
68 | moveForward(7) | |
69 | turtle.turnLeft() | |
70 | for j=1, 16, 1 do | |
71 | local slot = turtle.getItemDetail(j) | |
72 | - | local function calculateFuel(number_of_corridors) |
72 | + | |
73 | - | local fields_to_move = (number_of_corridors * 40) + (6 * math.ceil(number_of_corridors / 2)) |
73 | + | |
74 | - | return math.ceil(fields_to_move / 80) |
74 | + | |
75 | turtle.drop() | |
76 | end | |
77 | - | local function calculateTorches(number_of_corridors) |
77 | + | |
78 | - | local additionalTorches = math.ceil(number_of_corridors / 2) |
78 | + | |
79 | - | return (number_of_corridors * 2) + additionalTorches |
79 | + | |
80 | end | |
81 | ||
82 | local function calculateFuel(numberOfCorridors) | |
83 | return (numberOfCorridors * 40) + (6 * math.ceil(numberOfCorridors / 2)) | |
84 | end | |
85 | ||
86 | local function calculateTorches(numberOfCorridors) | |
87 | local additionalTorches = math.ceil(numberOfCorridors / 2) | |
88 | return (numberOfCorridors * 2) + additionalTorches | |
89 | end | |
90 | ||
91 | local function printWithConfirmation(string) | |
92 | - | local number_of_corridors = tonumber(read()) |
92 | + | |
93 | - | printWithConfirmation("Please provide " .. calculateFuel(number_of_corridors) .. " coal items in slot 1.") |
93 | + | |
94 | - | printWithConfirmation("Please provide " .. calculateTorches(number_of_corridors) .. " torches in slot 2.") |
94 | + | |
95 | os.shutdown() | |
96 | end | |
97 | - | stripMine(number_of_corridors) |
97 | + | |
98 | ||
99 | print("Ultimate Miner by KingKevin23") | |
100 | print("How many corridors should be mined?") | |
101 | local numberOfCorridors = tonumber(read()) | |
102 | print("Should I place torches? (y/n)") | |
103 | local placeTorches = read() == "y" | |
104 | local fuelNeeded = calculateFuel(numberOfCorridors) - turtle.getFuelLevel() | |
105 | if fuelNeeded > 0 then | |
106 | printWithConfirmation("Please provide " .. math.ceil(fuelNeeded / 80) .. " coal items in slot 1. \n Alternatively you can manually fuel with " .. math.ceil(fuelNeeded / 1000) .. " lava!") | |
107 | end | |
108 | ||
109 | if placeTorches then | |
110 | printWithConfirmation("Please provide " .. calculateTorches(numberOfCorridors) .. " torches in slot 2.") | |
111 | end | |
112 | turtle.select(1) | |
113 | turtle.refuel() | |
114 | stripMine(numberOfCorridors, placeTorches) |