Xgamer911

Ceiling

May 30th, 2015
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. params = {...}
  2. -- The input is text so we convert the text to a number.
  3. floorLength = tonumber(params[1])
  4. floorWidth = tonumber(params[2])
  5.  
  6. currentSlot = 1
  7.  
  8. -- This variable is used to alternate which way we are turning.
  9. turnRight = true
  10.  
  11. function gotoNextSlotIfEmpty()
  12.   if turtle.getItemCount(currentSlot) == 0 then
  13.     currentSlot = currentSlot + 1
  14.     turtle.select(currentSlot)
  15.   end
  16. end
  17.  
  18. function refuel()
  19. fuel = turtle.getFuelLevel()
  20. if fuel < 5 then
  21.         turtle.select(16)
  22.         turtle.refuel(1)
  23.         turtle.select(currentSlot)
  24.     end
  25. end
  26.  
  27. turtle.select(currentSlot)
  28. -- turtle.up()
  29.  
  30. for width = 1, floorWidth do
  31.  
  32.   for length = 1, floorLength do
  33.    
  34.     refuel()
  35.     turtle.placeUp()
  36.     gotoNextSlotIfEmpty()
  37.     if length ~= floorLength then
  38.       turtle.forward()
  39.     end
  40.    
  41.   end
  42.  
  43.   -- When you get to the end of a row of blocks you need to turn around and setup for the next row,
  44.   -- but every time you turn around you need to alternate the way that you turn.
  45.   -- If this is confusing try drawing it out on a peice of paper.
  46.   if turnRight then
  47.     turtle.turnRight()
  48.     turtle.forward()
  49.     turtle.turnRight()
  50.   else
  51.     turtle.turnLeft()
  52.     turtle.forward()
  53.     turtle.turnLeft()
  54.   end
  55.  
  56.   -- Change so that we turn the other way next time.
  57.   turnRight = not turnRight
  58. end
Advertisement
Add Comment
Please, Sign In to add comment