SHOW:
|
|
- or go back to the newest paste.
| 1 | -- Function to refuel the turtle | |
| 2 | local function refuelTurtle() | |
| 3 | -- Check if the turtle has fuel | |
| 4 | if turtle.getFuelLevel() < 10 then | |
| 5 | local slot = 1 | |
| 6 | while slot <= 16 do | |
| 7 | -- Find the first slot with fuel | |
| 8 | local item = turtle.getItemDetail(slot) | |
| 9 | if item and turtle.select(slot) and turtle.refuel(1) then | |
| 10 | print("Refueled from slot", slot)
| |
| 11 | turtle.select(1) | |
| 12 | return | |
| 13 | end | |
| 14 | slot = slot + 1 | |
| 15 | end | |
| 16 | print("No fuel found. Please refuel the turtle.")
| |
| 17 | os.shutdown() | |
| 18 | end | |
| 19 | end | |
| 20 | ||
| 21 | -- Parse the command line argument for the length of the mining area | |
| 22 | local args = {...}
| |
| 23 | local length = tonumber(args[1]) or 0 | |
| 24 | ||
| 25 | print("Length of Mining Area:", length) -- Print the parsed length
| |
| 26 | ||
| 27 | if length <= 0 then | |
| 28 | print("Usage: myprogram <length>")
| |
| 29 | return | |
| 30 | end | |
| 31 | ||
| 32 | ||
| 33 | -- Main mining loop | |
| 34 | local blocksMined = 0 | |
| 35 | while blocksMined < length do | |
| 36 | refuelTurtle() -- Check and refuel the turtle if necessary | |
| 37 | turtle.dig() | |
| 38 | turtle.forward() | |
| 39 | - | turtle.digUp() |
| 39 | + | |
| 40 | blocksMined = blocksMined + 1 | |
| 41 | ||
| 42 | -- Check if we've reached the specified length | |
| 43 | if blocksMined >= length then | |
| 44 | break | |
| 45 | end | |
| 46 | end | |
| 47 |