Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Get input
- local lw={...}
- local slot=1
- local w
- local l
- if #lw~=2 then
- print("Usage: fill <length> <width>")
- return
- end
- for i=1,2 do
- lw[i]=tonumber(lw[i])
- end
- turtle.select(slot)
- --
- local function forward()
- if turtle.getFuelLevel() == 0 then
- if not turtle.refuel() then
- print("I need fuel!")
- while not turtle.refuel() do
- sleep(0.5)
- end
- end
- end
- while not turtle.placeDown() do
- if turtle.getItemCount(slot)==0 then
- slot=slot+1
- if not turtle.select(slot) then
- return false
- end
- else
- turtle.digDown()
- end
- end
- if not turtle.forward() then
- turtle.dig()
- turtle.forward()
- end
- end
- --Fill
- for w=1,lw[2] do --width
- for l=2,lw[1] do --length
- forward()
- end
- if w%2==1 then
- turtle.turnRight()
- forward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- forward()
- turtle.turnLeft()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment