SHOW:
|
|
- or go back to the newest paste.
| 1 | DumpChestSlot = 1 | |
| 2 | FuelChestSlot = 2 | |
| 3 | GravityWait = 0.5 | |
| 4 | ItemChestSlot = 3 | |
| 5 | ItemSlot = 4 | |
| 6 | SpaceBegin = 5 | |
| 7 | SpaceEnd = 16 | |
| 8 | ||
| 9 | Args = {...}
| |
| 10 | L, W, H = tonumber(Args[1]), tonumber(Args[2]), tonumber(Args[3]) | |
| 11 | - | l, w, h |
| 11 | + | |
| 12 | function build() | |
| 13 | if turtle.getItemCount(ItemSlot) == 0 then | |
| 14 | turtle.select(ItemChestSlot) | |
| 15 | turtle.placeDown() | |
| 16 | turtle.select(ItemSlot) | |
| 17 | turtle.suckDown() | |
| 18 | turtle.select(ItemChestSlot) | |
| 19 | turtle.digDown() | |
| 20 | end | |
| 21 | if needSpace() then | |
| 22 | turtle.select(DumpChestSlot) | |
| 23 | turtle.placeDown() | |
| 24 | for slot = SpaceBegin, SpaceEnd do | |
| 25 | turtle.select(slot) | |
| 26 | turtle.dropDown() | |
| 27 | end | |
| 28 | turtle.select(DumpChestSlot) | |
| 29 | turtle.digDown() | |
| 30 | end | |
| 31 | turtle.select(ItemSlot) | |
| 32 | return turtle.placeDown() | |
| 33 | end | |
| 34 | ||
| 35 | function move() | |
| 36 | turtle.select(SpaceBegin) | |
| 37 | while turtle.dig() do | |
| 38 | os.sleep(GravityWait) | |
| 39 | end | |
| 40 | if needFuel() then | |
| 41 | turtle.select(FuelChestSlot) | |
| 42 | turtle.place() | |
| 43 | turtle.suck() | |
| 44 | turtle.refuel() | |
| 45 | turtle.dig() | |
| 46 | end | |
| 47 | return turtle.forward() | |
| 48 | end | |
| 49 | ||
| 50 | function moveUp() | |
| 51 | turtle.select(SpaceBegin) | |
| 52 | while turtle.digUp() do | |
| 53 | os.sleep(GravityWait) | |
| 54 | end | |
| 55 | if needFuel() then | |
| 56 | turtle.select(FuelChestSlot) | |
| 57 | turtle.placeUp() | |
| 58 | turtle.suckUp() | |
| 59 | turtle.refuel() | |
| 60 | turtle.digUp() | |
| 61 | end | |
| 62 | return turtle.up() | |
| 63 | end | |
| 64 | ||
| 65 | function needFuel() | |
| 66 | if (turtle.getFuelLimit() == "unlimited") or (turtle.getFuelLevel() > 0) then | |
| 67 | - | if turtle.getFuelLimit() == "unlimited" or turtle.getFuelLevel() > 0 then |
| 67 | + | |
| 68 | end | |
| 69 | return true | |
| 70 | end | |
| 71 | ||
| 72 | function needSpace() | |
| 73 | for slot = SpaceBegin, SpaceEnd do | |
| 74 | if turtle.getItemCount(slot) == 0 then | |
| 75 | return false | |
| 76 | end | |
| 77 | end | |
| 78 | return true | |
| 79 | end | |
| 80 | ||
| 81 | function surface() | |
| 82 | return (l == 1 or l == L or w == 1 or l == L or h == 1 or h == H) | |
| 83 | end | |
| 84 | ||
| 85 | for h = 1, H do | |
| 86 | moveUp() | |
| 87 | - | up() |
| 87 | + | |
| 88 | for l = 1, L do | |
| 89 | if surface() then | |
| 90 | build() | |
| 91 | end | |
| 92 | move() | |
| 93 | - | forward() |
| 93 | + | |
| 94 | local turn | |
| 95 | if (w % 2) == 0 then | |
| 96 | turn = turtle.turnRight | |
| 97 | else | |
| 98 | turn = turtle.turnLeft | |
| 99 | end | |
| 100 | turn() | |
| 101 | move() | |
| 102 | - | forward() |
| 102 | + | |
| 103 | end | |
| 104 | if (w % 2) == 1 then | |
| 105 | turtle.turnRight() | |
| 106 | turtle.turnRight() | |
| 107 | for l = 1, L do | |
| 108 | move() | |
| 109 | - | forward() |
| 109 | + | |
| 110 | end | |
| 111 | turtle.turnRight() | |
| 112 | for w = 1, W do | |
| 113 | move() | |
| 114 | - | forward() |
| 114 | + | |
| 115 | turtle.turnRight() | |
| 116 | end |