SHOW:
|
|
- or go back to the newest paste.
| 1 | - | -- Offshore Quarry Setup |
| 1 | + | -- Chunk land mark |
| 2 | local args = {...}
| |
| 3 | ||
| 4 | - | -- Check if there 3 arguments |
| 4 | + | -- Check if there arguments |
| 5 | if #args ~= 1 then | |
| 6 | - | print("Usage: OffshoreQuarrySetup <L/R>")
|
| 6 | + | print("Usage: landmark <L/R>")
|
| 7 | return | |
| 8 | end | |
| 9 | ||
| 10 | - | local dir = "L" |
| 10 | + | dir = "L" |
| 11 | dir = args[1] | |
| 12 | ||
| 13 | if dir == "l" or dir == "L" then | |
| 14 | dir = "L" | |
| 15 | else | |
| 16 | dir = "R" | |
| 17 | end | |
| 18 | ||
| 19 | local function tryDig() | |
| 20 | while turtle.detect() do | |
| 21 | if turtle.dig() then | |
| 22 | sleep(0.3) | |
| 23 | else | |
| 24 | return false | |
| 25 | end | |
| 26 | end | |
| 27 | return true | |
| 28 | end | |
| 29 | ||
| 30 | local function tryDigUp() | |
| 31 | while turtle.detectUp() do | |
| 32 | if turtle.digUp() then | |
| 33 | sleep(0.3) | |
| 34 | else | |
| 35 | return false | |
| 36 | end | |
| 37 | end | |
| 38 | return true | |
| 39 | end | |
| 40 | ||
| 41 | local function refuel() | |
| 42 | local fuelLevel = turtle.getFuelLevel() | |
| 43 | if fuelLevel == "unlimited" or fuelLevel > 0 then | |
| 44 | return | |
| 45 | end | |
| 46 | ||
| 47 | local function tryRefuel() | |
| 48 | for n=1,16 do | |
| 49 | if turtle.getItemCount(n) > 0 then | |
| 50 | turtle.select(n) | |
| 51 | if turtle.refuel(1) then | |
| 52 | turtle.select(1) | |
| 53 | return true | |
| 54 | end | |
| 55 | end | |
| 56 | end | |
| 57 | turtle.select(1) | |
| 58 | return false | |
| 59 | end | |
| 60 | ||
| 61 | if not tryRefuel() then | |
| 62 | print( "Add more fuel to continue." ) | |
| 63 | while not tryRefuel() do | |
| 64 | sleep(1) | |
| 65 | end | |
| 66 | print( "Resuming Quarry Setup." ) | |
| 67 | end | |
| 68 | end | |
| 69 | ||
| 70 | ||
| 71 | local function tryForward() | |
| 72 | refuel() | |
| 73 | while not turtle.forward() do | |
| 74 | if turtle.detect() then | |
| 75 | if not tryDig() then | |
| 76 | - | -- dig |
| 76 | + | |
| 77 | end | |
| 78 | elseif turtle.attack() then | |
| 79 | -- collect() | |
| 80 | - | turtle.placeDown() |
| 80 | + | |
| 81 | - | |
| 81 | + | |
| 82 | - | if n<17 then |
| 82 | + | |
| 83 | end | |
| 84 | return true | |
| 85 | end | |
| 86 | ||
| 87 | local function cornerMark() | |
| 88 | turtle.digDown() | |
| 89 | turtle.select(2) | |
| 90 | turtle.placeDown() | |
| 91 | if dir == "L" then | |
| 92 | turtle.turnLeft() | |
| 93 | else | |
| 94 | turtle.turnRight() | |
| 95 | end | |
| 96 | tryDig() | |
| 97 | tryDigUp() | |
| 98 | turtle.turnLeft() | |
| 99 | - | turtle.placeDown() |
| 99 | + | turtle.turnLeft() |
| 100 | - | |
| 100 | + | turtle.back() |
| 101 | - | if n<17 then |
| 101 | + | turtle.select(1) |
| 102 | turtle.place() | |
| 103 | turtle.turnLeft() | |
| 104 | turtle.turnLeft() | |
| 105 | end | |
| 106 | ||
| 107 | for i=1,2 do | |
| 108 | for n=1,17 do | |
| 109 | if n<16 then | |
| 110 | tryDig() | |
| 111 | tryDigUp() | |
| 112 | if not tryForward() then | |
| 113 | print( "Aborting Setup." ) | |
| 114 | break | |
| 115 | end | |
| 116 | else | |
| 117 | print( "Segment complete." ) | |
| 118 | end | |
| 119 | ||
| 120 | end | |
| 121 | cornerMark() | |
| 122 | for n=1,17 do | |
| 123 | if n<16 then | |
| 124 | tryDig() | |
| 125 | tryDigUp() | |
| 126 | if not tryForward() then | |
| 127 | print( "Aborting Setup." ) | |
| 128 | break | |
| 129 | end | |
| 130 | else | |
| 131 | print( "Segment complete." ) | |
| 132 | end | |
| 133 | ||
| 134 | end | |
| 135 | cornerMark() | |
| 136 | end | |
| 137 | ||
| 138 | turtle.select(2) | |
| 139 | turtle.placeDown() | |
| 140 | ||
| 141 | print( "Chunk delimited." ) |