logg

Untitled

Mar 6th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
  35. end
  36. --Fill
  37. for w=1,lw[2] do --width
  38.   for l=2,lw[1] do --length
  39.     forward()
  40.   end
  41.   if w%2==1 then
  42.     turtle.turnRight()
  43.     forward()
  44.     turtle.turnRight()
  45.   else
  46.     turtle.turnLeft()
  47.     forward()
  48.     turtle.turnLeft()
  49.   end
  50. end
Advertisement
Add Comment
Please, Sign In to add comment