SHOW:
|
|
- or go back to the newest paste.
| 1 | local tArgs = { ... }
| |
| 2 | ||
| 3 | local digDownAmount | |
| 4 | local digDeepAmount | |
| 5 | local stripeAmount | |
| 6 | ||
| 7 | - | local fuelSlot = 1 |
| 7 | + | |
| 8 | print ("You need exactly three parameter!")
| |
| 9 | - | local stripeIndex = 1 |
| 9 | + | |
| 10 | - | local digDeepIndex = 1 |
| 10 | + | |
| 11 | digDownAmount = tonumber(tArgs[1]) | |
| 12 | digDeepAmount = tonumber(tArgs[2]) | |
| 13 | stripeAmount = tonumber(tArgs[3]) | |
| 14 | end | |
| 15 | ||
| 16 | local function forward() | |
| 17 | while not turtle.forward() do | |
| 18 | if not turtle.dig() then | |
| 19 | turtle.attack() | |
| 20 | sleep(0.5) | |
| 21 | end | |
| 22 | end | |
| 23 | end | |
| 24 | ||
| 25 | local fucntion up() | |
| 26 | while not turtle.up() do | |
| 27 | if not turtle.digUp() then | |
| 28 | turtle.attackUp() | |
| 29 | sleep(0.5) | |
| 30 | - | local function up() |
| 30 | + | |
| 31 | end | |
| 32 | end | |
| 33 | ||
| 34 | local function down() | |
| 35 | while not turtle.down() do | |
| 36 | if not turtle.digDown() then | |
| 37 | turtle.attackDown() | |
| 38 | sleep(0.5) | |
| 39 | end | |
| 40 | end | |
| 41 | end | |
| 42 | ||
| 43 | local function FindChest() | |
| 44 | local turns = 0 | |
| 45 | local chestFound = false | |
| 46 | while not ChestFound do | |
| 47 | for i = 1, 4 do | |
| 48 | if turtle.detect() then | |
| 49 | print("Chest found... starting mine operation!")
| |
| 50 | ChestFound = true | |
| 51 | break | |
| 52 | else | |
| 53 | - | return |
| 53 | + | |
| 54 | end | |
| 55 | end | |
| 56 | print("No Chest found.. place a chest near turtle to start mining")
| |
| 57 | sleep(3) | |
| 58 | end | |
| 59 | end | |
| 60 | ||
| 61 | local function mineToBase(amount) | |
| 62 | turtle.select(1) | |
| 63 | for i = 1, amount do | |
| 64 | - | turtle.select(fuelSlot + 1) |
| 64 | + | |
| 65 | turtle.placeUp() | |
| 66 | end | |
| 67 | end | |
| 68 | ||
| 69 | - | print("Arrived at mining level.. start mining")
|
| 69 | + | |
| 70 | turtle.select(1) | |
| 71 | for i = 1, amount do | |
| 72 | up() | |
| 73 | - | turtle.select(fuelSlot + 1) |
| 73 | + | |
| 74 | end | |
| 75 | end | |
| 76 | ||
| 77 | local function DigRow() | |
| 78 | - | print("Arrived at starting level.. empting inventory")
|
| 78 | + | |
| 79 | forward() | |
| 80 | turtle.digDown() | |
| 81 | - | -- Returns false if inventory full |
| 81 | + | |
| 82 | - | local function ContinueDigging() |
| 82 | + | |
| 83 | - | -- Check inventory |
| 83 | + | |
| 84 | - | if (turtle.getItemCount(16) >= 0) then |
| 84 | + | |
| 85 | - | return false |
| 85 | + | for i = 1, 16 do |
| 86 | turtle.select(i) | |
| 87 | turtle.drop() | |
| 88 | end | |
| 89 | end | |
| 90 | ||
| 91 | local function FirstMining(amount) | |
| 92 | for i = 1, amount do | |
| 93 | DigRow() | |
| 94 | end | |
| 95 | ||
| 96 | turtle.turnLeft() | |
| 97 | - | if not turtle.detect() then |
| 97 | + | |
| 98 | - | print("No Block to place items into")
|
| 98 | + | |
| 99 | - | return |
| 99 | + | |
| 100 | - | end |
| 100 | + | |
| 101 | - | -- Fuel is in slot 1, never empty this |
| 101 | + | |
| 102 | - | for i = 2, 16 do |
| 102 | + | |
| 103 | end | |
| 104 | ||
| 105 | local function MiningLoop(amount) | |
| 106 | - | print("Inventory successfully emptied")
|
| 106 | + | |
| 107 | FirstMining(digDeepAmount) | |
| 108 | ||
| 109 | turtle.turnRight() | |
| 110 | for i = 1, 2 do | |
| 111 | - | if ContinueDigging() then |
| 111 | + | turtle.dig() |
| 112 | - | DigRow() |
| 112 | + | forward() |
| 113 | - | digDeepAmount = digDeepAmount + 1 |
| 113 | + | |
| 114 | - | else |
| 114 | + | |
| 115 | - | break |
| 115 | + | |
| 116 | ||
| 117 | turtle.turnLeft() | |
| 118 | for i = 1, amount * 3 do | |
| 119 | forward() | |
| 120 | end | |
| 121 | - | while (digDeepAmount > 1) do |
| 121 | + | |
| 122 | end | |
| 123 | - | digDeepAmount = digDeepAmount - 1 |
| 123 | + | |
| 124 | FindChest() | |
| 125 | mineToBase(digDownAmount) | |
| 126 | MiningLoop(stripeAmount) | |
| 127 | moveToTop(digDownAmount) | |
| 128 | EmptyInventory() | |
| 129 | print ("Run successfully!") |