SHOW:
|
|
- or go back to the newest paste.
| 1 | - | -- TL4ptrYd |
| 1 | + | -- pk6NUgbg |
| 2 | - | local tArgs = { ... }
|
| 2 | + | --local tArgs = { ... }
|
| 3 | - | if #tArgs ~= 1 then |
| 3 | + | --if #tArgs ~= 1 then |
| 4 | - | print( "Usage: tunnel <length>" ) |
| 4 | + | -- print( "Usage: tunnel <length>" ) |
| 5 | - | return |
| 5 | + | -- return |
| 6 | --end | |
| 7 | term.clear() | |
| 8 | print( " Diese Programm dient zum Faellen eine Mammuts Baum") | |
| 9 | - | local length = tonumber( tArgs[1] ) |
| 9 | + | print() |
| 10 | - | if length < 1 then |
| 10 | + | write( " Wie hoch ist der Baum ? ") |
| 11 | - | print( "Tunnel length must be positive" ) |
| 11 | + | length=io.read() |
| 12 | - | return |
| 12 | + | print() |
| 13 | print( " Wir gehen "..length.." Bloecke hoch um den Baum zu faellen.") | |
| 14 | ||
| 15 | -- Mine in a quarry pattern until we hit something we can't dig | |
| 16 | --local length = tonumber( tArgs[1] ) | |
| 17 | --if length < 1 then | |
| 18 | -- print( "Tunnel length must be positive" ) | |
| 19 | -- return | |
| 20 | --end | |
| 21 | ||
| 22 | local depth = length | |
| 23 | local collected = 0 | |
| 24 | ||
| 25 | local function collect() | |
| 26 | collected = collected + 1 | |
| 27 | if math.fmod(collected, 25) == 0 then | |
| 28 | print( "Mined "..collected.." items." ) | |
| 29 | end | |
| 30 | end | |
| 31 | ||
| 32 | local function tryDig() | |
| 33 | while turtle.detect() do | |
| 34 | if turtle.dig() then | |
| 35 | collect() | |
| 36 | sleep(0.5) | |
| 37 | else | |
| 38 | return false | |
| 39 | end | |
| 40 | end | |
| 41 | return true | |
| 42 | end | |
| 43 | ||
| 44 | local function tryDigUp() | |
| 45 | while turtle.detectUp() do | |
| 46 | if turtle.digUp() then | |
| 47 | collect() | |
| 48 | sleep(0.5) | |
| 49 | else | |
| 50 | return false | |
| 51 | end | |
| 52 | end | |
| 53 | return true | |
| 54 | end | |
| 55 | ||
| 56 | local function refuel() | |
| 57 | local fuelLevel = turtle.getFuelLevel() | |
| 58 | if fuelLevel == "unlimited" or fuelLevel > 0 then | |
| 59 | return | |
| 60 | end | |
| 61 | ||
| 62 | local function tryRefuel() | |
| 63 | for n=1,16 do | |
| 64 | if turtle.getItemCount(n) > 0 then | |
| 65 | turtle.select(n) | |
| 66 | if turtle.refuel(1) then | |
| 67 | turtle.select(1) | |
| 68 | return true | |
| 69 | end | |
| 70 | end | |
| 71 | end | |
| 72 | turtle.select(1) | |
| 73 | return false | |
| 74 | end | |
| 75 | ||
| 76 | if not tryRefuel() then | |
| 77 | print( "Add more fuel to continue." ) | |
| 78 | while not tryRefuel() do | |
| 79 | sleep(1) | |
| 80 | end | |
| 81 | print( "Resuming Tunnel." ) | |
| 82 | end | |
| 83 | end | |
| 84 | ||
| 85 | local function tryUp() | |
| 86 | refuel() | |
| 87 | while not turtle.up() do | |
| 88 | if turtle.detectUp() then | |
| 89 | if not tryDigUp() then | |
| 90 | return false | |
| 91 | end | |
| 92 | elseif turtle.attackUp() then | |
| 93 | collect() | |
| 94 | else | |
| 95 | sleep( 0.5 ) | |
| 96 | end | |
| 97 | end | |
| 98 | return true | |
| 99 | end | |
| 100 | ||
| 101 | local function tryDown() | |
| 102 | refuel() | |
| 103 | while not turtle.down() do | |
| 104 | if turtle.detectDown() then | |
| 105 | if not turtle.digDown() then | |
| 106 | return false | |
| 107 | end | |
| 108 | elseif turtle.attackDown() then | |
| 109 | collect() | |
| 110 | else | |
| 111 | sleep( 0.5 ) | |
| 112 | end | |
| 113 | end | |
| 114 | return true | |
| 115 | end | |
| 116 | ||
| 117 | local function tryForward() | |
| 118 | refuel() | |
| 119 | while not turtle.forward() do | |
| 120 | if turtle.detect() then | |
| 121 | if not tryDig() then | |
| 122 | return false | |
| 123 | end | |
| 124 | elseif turtle.attack() then | |
| 125 | collect() | |
| 126 | - | print( " Fackeln in Slot 15 ") |
| 126 | + | |
| 127 | - | print( "Tunnelling..." ) |
| 127 | + | |
| 128 | end | |
| 129 | end | |
| 130 | - | pro = 100/length*n |
| 130 | + | |
| 131 | - | turtle.placeDown() |
| 131 | + | |
| 132 | - | tryDigUp() |
| 132 | + | |
| 133 | ||
| 134 | - | for UP=1,25 do |
| 134 | + | print( " Baum faellen..." ) |
| 135 | - | tryDig() |
| 135 | + | |
| 136 | for nu=1,length do | |
| 137 | tryUp() | |
| 138 | - | tryDig() |
| 138 | + | |
| 139 | - | turtle.turnRight() |
| 139 | + | |
| 140 | - | turtle.turnRight() |
| 140 | + | pro = 100/length*n |
| 141 | - | tryForward() |
| 141 | + | for Flaeche=1,6 do |
| 142 | - | for DW=1,25 do |
| 142 | + | for go1=1,12 do |
| 143 | - | tryDig() |
| 143 | + | tryDig() |
| 144 | tryForward() | |
| 145 | end | |
| 146 | - | tryDig() |
| 146 | + | turtle.turnRight() |
| 147 | - | j = j+1 |
| 147 | + | -- print("1")
|
| 148 | - | if j == 5 then |
| 148 | + | |
| 149 | - | turtle.select(15) |
| 149 | + | -- print("2")
|
| 150 | - | turtle.placeDown() |
| 150 | + | tryForward() |
| 151 | - | j = 0 |
| 151 | + | -- print("3")
|
| 152 | - | end |
| 152 | + | turtle.turnRight() |
| 153 | -- print("4")
| |
| 154 | for go2=1,12 do | |
| 155 | tryDig() | |
| 156 | - | tryForward() |
| 156 | + | tryForward() |
| 157 | - | turtle.turnRight() |
| 157 | + | |
| 158 | turtle.turnLeft() | |
| 159 | - | if n<length then |
| 159 | + | |
| 160 | tryForward() | |
| 161 | - | if not tryForward() then |
| 161 | + | turtle.turnLeft() |
| 162 | - | print( "Aborting Tunnel." ) |
| 162 | + | |
| 163 | - | break |
| 163 | + | for go3=1,12 do |
| 164 | tryDig() | |
| 165 | - | else |
| 165 | + | tryForward() |
| 166 | - | print( "Tunnel complete." ) |
| 166 | + | |
| 167 | turtle.turnLeft() | |
| 168 | turtle.turnLeft() | |
| 169 | tryDown() | |
| 170 | term.setCursorPos(1,6) | |
| 171 | term.clearLine() | |
| 172 | - | print( "Mined "..collected.." items total." ) |
| 172 | + | |
| 173 | end | |
| 174 | --if n<length then | |
| 175 | -- if not tryDown() then | |
| 176 | -- print( "Aborting Tunnel." ) | |
| 177 | -- break | |
| 178 | -- end | |
| 179 | --else | |
| 180 | -- print( "Tunnel complete." ) | |
| 181 | --end | |
| 182 | ||
| 183 | ||
| 184 | print( "Tunnel complete." ) | |
| 185 | --print( "Mined "..collected.." items total." ) |