SHOW:
|
|
- or go back to the newest paste.
| 1 | --Get input | |
| 2 | local lw={...}
| |
| 3 | local slot=1 | |
| 4 | local w | |
| 5 | local l | |
| 6 | if #lw~=2 then | |
| 7 | print("Usage: fill <length> <width>")
| |
| 8 | return | |
| 9 | end | |
| 10 | for i=1,2 do | |
| 11 | lw[i]=tonumber(lw[i]) | |
| 12 | end | |
| 13 | turtle.select(slot) | |
| 14 | -- | |
| 15 | local function forward() | |
| 16 | if turtle.getFuelLevel() == 0 then | |
| 17 | if not turtle.refuel() then | |
| 18 | print("I need fuel!")
| |
| 19 | while not turtle.refuel() do | |
| 20 | sleep(0.5) | |
| 21 | end | |
| 22 | end | |
| 23 | end | |
| 24 | while not turtle.placeDown() do | |
| 25 | if turtle.getItemCount(slot)==0 then | |
| 26 | slot=slot+1 | |
| 27 | if not turtle.select(slot) then | |
| 28 | return false | |
| 29 | end | |
| 30 | else | |
| 31 | turtle.digDown() | |
| 32 | end | |
| 33 | end | |
| 34 | - | turtle.forward() |
| 34 | + | if not turtle.forward() then |
| 35 | turtle.dig() | |
| 36 | turtle.forward() | |
| 37 | end | |
| 38 | end | |
| 39 | --Fill | |
| 40 | for w=1,lw[2] do --width | |
| 41 | for l=2,lw[1] do --length | |
| 42 | forward() | |
| 43 | end | |
| 44 | if w%2==1 then | |
| 45 | turtle.turnRight() | |
| 46 | forward() | |
| 47 | turtle.turnRight() | |
| 48 | else | |
| 49 | turtle.turnLeft() | |
| 50 | forward() | |
| 51 | turtle.turnLeft() | |
| 52 | end | |
| 53 | end |