SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local x = 8 |
| 1 | + | local args = {...}
|
| 2 | - | local y = 9 |
| 2 | + | |
| 3 | - | local z = 4 |
| 3 | + | if not #args == 3 then |
| 4 | print("Usage: clear <x y z>")
| |
| 5 | return | |
| 6 | end | |
| 7 | ||
| 8 | ||
| 9 | - | print("Not enough fuel")
|
| 9 | + | local x = tonumber(args[1]) - 1 |
| 10 | local y = tonumber(args[2]) | |
| 11 | local z = tonumber(args[3]) | |
| 12 | ||
| 13 | if x == nil or y == nil or z == nil then | |
| 14 | print("Invalid dimensions")
| |
| 15 | return | |
| 16 | end | |
| 17 | ||
| 18 | if x < 0 or y < 0 or z < 0 then | |
| 19 | print("Invalid (negative) dimensions")
| |
| 20 | return | |
| 21 | end | |
| 22 | ||
| 23 | local fuel = turtle.getFuelLevel() | |
| 24 | local roomSize = x * y * z | |
| 25 | while fuel < roomSize do | |
| 26 | if not turtle.refuel(1) then | |
| 27 | print("Not enough fuel, needs " .. roomSize .. " fuel do dig, add " .. (roomSize-fuel) .. " more to dig this size")
| |
| 28 | return | |
| 29 | end | |
| 30 | end | |
| 31 | ||
| 32 | local direction = true | |
| 33 | for i = 1, z do | |
| 34 | for j = 1, y do | |
| 35 | for k = 1, x do | |
| 36 | turtle.dig() | |
| 37 | while not turtle.forward() do turtle.dig() end | |
| 38 | - | turtle.digUp() |
| 38 | + | |
| 39 | - | while not turtle.up() do turtle.digUp() end |
| 39 | + | |
| 40 | if direction then | |
| 41 | turtle.turnRight() | |
| 42 | turtle.dig() | |
| 43 | while not turtle.forward() do turtle.dig() end | |
| 44 | turtle.turnRight() | |
| 45 | direction = false | |
| 46 | else | |
| 47 | turtle.turnLeft() | |
| 48 | turtle.dig() | |
| 49 | while not turtle.forward() do turtle.dig() end | |
| 50 | turtle.turnLeft() | |
| 51 | direction = true | |
| 52 | end | |
| 53 | end | |
| 54 | end | |
| 55 | if i < z then | |
| 56 | turtle.digDown() | |
| 57 | while not turtle.down() do turtle.digDown() end | |
| 58 | turtle.turnRight() | |
| 59 | turtle.turnRight() | |
| 60 | end | |
| 61 | end |