SHOW:
|
|
- or go back to the newest paste.
| 1 | local tArgs = { ... }
| |
| 2 | ||
| 3 | function showHelp() | |
| 4 | print("Usage:")
| |
| 5 | print("stripmine <length> <deep>")
| |
| 6 | print("length > 0")
| |
| 7 | print("deep > -1")
| |
| 8 | print("if deep is empty: deep = 5")
| |
| 9 | end | |
| 10 | ||
| 11 | if #tArgs == 1 then | |
| 12 | if tArgs[1] == "help" or tArgs[1] == "?" then | |
| 13 | showHelp() | |
| 14 | return | |
| 15 | end | |
| 16 | length = tArgs[1] | |
| 17 | deep = 5 | |
| 18 | elseif #tArgs == 2 then | |
| 19 | length = tArgs[1] | |
| 20 | deep = tArgs[2] | |
| 21 | if length < "1" and deep < "0" then | |
| 22 | print("length > 0")
| |
| 23 | print("deep >= 0")
| |
| 24 | return | |
| 25 | end | |
| 26 | else | |
| 27 | showHelp() | |
| 28 | return | |
| 29 | end | |
| 30 | ||
| 31 | function forward(a) | |
| 32 | for i=1,a do | |
| 33 | while turtle.forward() == false do | |
| 34 | turtle.attack() | |
| 35 | turtle.dig() | |
| 36 | end | |
| 37 | end | |
| 38 | end | |
| 39 | ||
| 40 | function right(a) | |
| 41 | for i=1,a do | |
| 42 | turtle.turnRight() | |
| 43 | end | |
| 44 | end | |
| 45 | ||
| 46 | function left(a) | |
| 47 | for i=1,a do | |
| 48 | turtle.turnLeft() | |
| 49 | end | |
| 50 | end | |
| 51 | ||
| 52 | function dig(a) | |
| 53 | for i=1,a do | |
| 54 | lava() | |
| 55 | while turtle.detect()==true or turtle.forward() == false do | |
| 56 | turtle.dig() | |
| 57 | turtle.attack() | |
| 58 | sleep(0.3) | |
| 59 | end | |
| 60 | ||
| 61 | while turtle.detectUp()==true do | |
| 62 | turtle.attackUp() | |
| 63 | turtle.digUp() | |
| 64 | sleep(0.4) | |
| 65 | end | |
| 66 | end | |
| 67 | end | |
| 68 | ||
| 69 | function drop() | |
| 70 | for i=1,14 do | |
| 71 | turtle.select(i) | |
| 72 | turtle.drop() | |
| 73 | end | |
| 74 | turtle.select(1) | |
| 75 | end | |
| 76 | ||
| 77 | function lava() | |
| 78 | if turtle.getItemCount(15)>0 then | |
| 79 | turtle.select(15) | |
| 80 | turtle.place() | |
| 81 | if turtle.refuel() == false then | |
| 82 | --Whatever we picked up is invalid for fuel, put it back down | |
| 83 | turtle.place() | |
| 84 | end | |
| 85 | turtle.placeDown() | |
| 86 | if turtle.refuel() == false then | |
| 87 | --Whatever we picked up is invalid for fuel, put it back down | |
| 88 | turtle.placeDown() | |
| 89 | end | |
| 90 | turtle.placeUp() | |
| 91 | if turtle.refuel() == false then | |
| 92 | --Whatever we picked up is invalid for fuel, put it back down | |
| 93 | turtle.placeUp() | |
| 94 | end | |
| 95 | turtle.select(1) | |
| 96 | end | |
| 97 | end | |
| 98 | ||
| 99 | for j=1,length do | |
| 100 | print(j," of ", length) | |
| 101 | dig(3) | |
| 102 | turtle.back() | |
| 103 | turtle.select(16) | |
| 104 | turtle.placeUp() | |
| 105 | turtle.forward() | |
| 106 | right(1) | |
| 107 | dig(deep) | |
| 108 | left(2) | |
| 109 | forward(deep) | |
| 110 | dig(deep) | |
| 111 | right(2) | |
| 112 | forward(deep) | |
| 113 | left(1) | |
| 114 | if (j % 10) == 0 then | |
| 115 | right(2) | |
| 116 | forward(j*3) | |
| 117 | left(1) | |
| 118 | drop() | |
| 119 | left(1) | |
| 120 | forward(j*3) | |
| 121 | end | |
| 122 | end | |
| 123 | right(2) | |
| 124 | forward(length*3) | |
| 125 | left(1) | |
| 126 | drop() | |
| 127 | left(1) |