SHOW:
|
|
- or go back to the newest paste.
| 1 | local args = {...}
| |
| 2 | ||
| 3 | local stripLength = 32 | |
| 4 | local count = 0 | |
| 5 | ||
| 6 | if not #args == 1 then | |
| 7 | print("Usage: smine <mines>")
| |
| 8 | return | |
| 9 | end | |
| 10 | ||
| 11 | function strip() | |
| 12 | - | checkFuel() |
| 12 | + | count = 0 |
| 13 | for i=1,stripLength do | |
| 14 | count = count + 1 | |
| 15 | checkFuel(count) | |
| 16 | checkInv() | |
| 17 | while not turtle.forward() do turtle.dig() end | |
| 18 | while turtle.detectUp() do | |
| 19 | turtle.digUp() | |
| 20 | sleep(0.2) | |
| 21 | end | |
| 22 | while turtle.detectDown() do | |
| 23 | turtle.digDown() | |
| 24 | sleep(0.2) | |
| 25 | end | |
| 26 | ||
| 27 | - | while turtle.detectUp() do |
| 27 | + | |
| 28 | - | turtle.digUp() |
| 28 | + | |
| 29 | while not turtle.forward() do turtle.dig() end | |
| 30 | while turtle.detectDown() do | |
| 31 | turtle.digDown() | |
| 32 | sleep(0.2) | |
| 33 | end | |
| 34 | if not turtle.back() then | |
| 35 | turtle.turnLeft() | |
| 36 | turtle.turnLeft() | |
| 37 | while not turtle.forward do turtle.dig() end | |
| 38 | - | turtle.placeUp() |
| 38 | + | |
| 39 | turtle.turnLeft() | |
| 40 | end | |
| 41 | turtle.placeDown() | |
| 42 | turtle.select(1) | |
| 43 | end | |
| 44 | end | |
| 45 | ||
| 46 | turtle.turnLeft() | |
| 47 | turtle.turnLeft() | |
| 48 | ||
| 49 | for i=1,stripLength do | |
| 50 | while not turtle.forward() do turtle.dig() end | |
| 51 | - | function checkFuel() |
| 51 | + | |
| 52 | - | if turtle.getFuelLevel() <= 64 then |
| 52 | + | |
| 53 | ||
| 54 | function checkFuel(count) | |
| 55 | if turtle.getFuelLevel() <= count then | |
| 56 | print("Error: Low fuel")
| |
| 57 | for i=1,14 do | |
| 58 | turtle.select(i) | |
| 59 | turtle.refuel() | |
| 60 | end | |
| 61 | turtle.select(1) | |
| 62 | if turtle.getFuelLevel() <= count then | |
| 63 | turtle.turnLeft() | |
| 64 | turtle.turnLeft() | |
| 65 | print("returning")
| |
| 66 | print(count) | |
| 67 | for i=0,count do | |
| 68 | turtle.forward() | |
| 69 | end | |
| 70 | emptyInv() | |
| 71 | turtle.turnRight() | |
| 72 | end | |
| 73 | end | |
| 74 | end | |
| 75 | ||
| 76 | function checkInv() | |
| 77 | isFull = true | |
| 78 | ||
| 79 | for i=1,14 do | |
| 80 | if turtle.getItemCount(i) == 0 then | |
| 81 | isFull = false | |
| 82 | end | |
| 83 | end | |
| 84 | ||
| 85 | - | for y=1,3 do turtle.forward() end |
| 85 | + | |
| 86 | - | end |
| 86 | + | |
| 87 | while not turtle.placeDown() do turtle.digDown() end | |
| 88 | for i=1,14 do | |
| 89 | turtle.select(i) | |
| 90 | turtle.dropDown() | |
| 91 | end | |
| 92 | turtle.select(15) | |
| 93 | turtle.digDown() | |
| 94 | sleep(0.2) | |
| 95 | turtle.select(1) | |
| 96 | end | |
| 97 | end | |
| 98 | ||
| 99 | function emptyInv() | |
| 100 | turtle.select(15) | |
| 101 | while not turtle.placeDown() do turtle.digDown() end | |
| 102 | for i=1,14 do | |
| 103 | turtle.select(i) | |
| 104 | turtle.dropDown() | |
| 105 | end | |
| 106 | turtle.select(15) | |
| 107 | turtle.digDown() | |
| 108 | sleep(0.2) | |
| 109 | turtle.select(1) | |
| 110 | end | |
| 111 | ||
| 112 | for x=1,args[1] do | |
| 113 | turtle.turnLeft() | |
| 114 | strip() | |
| 115 | strip() | |
| 116 | turtle.turnRight() | |
| 117 | for y=1,3 do | |
| 118 | while not turtle.forward() do turtle.dig() end | |
| 119 | while turtle.detectUp() do | |
| 120 | turtle.digUp() | |
| 121 | sleep(0.2) | |
| 122 | end | |
| 123 | while turtle.detectDown() do | |
| 124 | turtle.digDown() | |
| 125 | sleep(0.2) | |
| 126 | end | |
| 127 | end | |
| 128 | turtle.select(16) | |
| 129 | turtle.placeDown() | |
| 130 | turtle.select(1) | |
| 131 | print("Mined " .. x .. ", " .. args[1]-x .. " left to go.")
| |
| 132 | end | |
| 133 | emptyInv() |