Advertisement
hoblin

Floor maker

Jan 8th, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. -- -----------------------------
  2. -- Floor maker
  3. -- pastebin get gt9FVdK8 floor
  4. -- -----------------------------
  5.  
  6. even = true
  7. current_slot = 2
  8. x_coord = 0
  9. y_coord = 0
  10.  
  11. write("Please enter floor lenth ")
  12. lenth = read()
  13. write("Please enter floor width ")
  14. width = read()
  15. write('Clear up block?')
  16. clear_up = read()
  17. if clear_up == 'y' or clear_up == '1' or clear_up == 'true' or clear_up == 'yes' then
  18.   clear_up = true
  19. else
  20.   clear_up = false
  21. end
  22.  
  23. function checkFuel()
  24.   while turtle.getFuelLevel() < 5 do
  25.     turtle.select(1)
  26.     turtle.refuel(1)
  27.     if turtle.getFuelLevel() < 5 then
  28.       sleep(5)
  29.     end
  30.   end
  31.   turtle.select(16)
  32. end
  33.  
  34. function placeBlock()
  35.   turtle.select(currentSlot())
  36.   if not turtle.compareDown() then
  37.     turtle.select(16)
  38.     turtle.digDown()
  39.     cleanSlot()
  40.     turtle.select(currentSlot())
  41.     turtle.placeDown()
  42.   end
  43.   turtle.select(16)
  44. end
  45.  
  46. function cleanSlot()
  47.   if(turtle.getItemCount(16) > 0) then turtle.dropUp() end
  48. end
  49.  
  50. function currentSlot()
  51.   if turtle.getItemCount(current_slot) < 2 then
  52.     found_slot = false
  53.     while not found_slot do
  54.       for i=2,15 do
  55.         if turtle.getItemCount(i) > 1 then
  56.           found_slot = i
  57.           break
  58.         end
  59.       end
  60.       if not found_slot then
  61.         print("Out of building materials. Please refill and press enter to continue.")
  62.         io.read()
  63.       else
  64.         current_slot = found_slot
  65.       end
  66.     end
  67.   end
  68.   return current_slot
  69. end
  70.  
  71. turtle.select(16)
  72. placeBlock()
  73. while y_coord < tonumber(width) do
  74.   while x_coord < (tonumber(lenth) - 1) do
  75.     x_coord = x_coord + 1
  76.     checkFuel()
  77.     while not turtle.forward() do
  78.       turtle.dig()
  79.       cleanSlot()
  80.     end
  81.     if clear_up and turtle.detectUp() then
  82.       turtle.digUp()
  83.       cleanSlot()
  84.     end
  85.     placeBlock()
  86.   end
  87.   x_coord = 0
  88.   y_coord = y_coord + 1
  89.   if even then
  90.     turtle.turnRight()
  91.     while not turtle.forward() do
  92.       turtle.dig()
  93.       cleanSlot()
  94.     end
  95.     turtle.turnRight()
  96.   else
  97.     turtle.turnLeft()
  98.     while not turtle.forward() do
  99.       turtle.dig()
  100.       cleanSlot()
  101.     end
  102.     turtle.turnLeft()
  103.   end
  104.   if (y_coord < tonumber(width)) then placeBlock() end
  105.   even = not even
  106. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement