logg

Untitled

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