Hopfi

fill_sand

May 15th, 2021 (edited)
768
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function checkBlockCap(cur_slot, depth)
  2.     -- check if there is enough cobble, otherwise
  3.     if turtle.getItemCount() <= depth then
  4.         cur_slot = cur_slot + 1
  5.         if cur_slot > 16 then
  6.             return false
  7.         else
  8.             turtle.select(cur_slot)
  9.             return true
  10.         end
  11.     end
  12. end
  13.  
  14. function fillUp(depth, cur_slot)
  15.     checkBlockCap(cur_slot, depth)
  16.     for i=1, depth, 1 do
  17.         turtle.placeDown()
  18.     end
  19. end
  20.  
  21. function fillSand(N, depth, cur_slot)
  22.     level_done = false
  23.     rows_done = 0
  24.     while not level_done do
  25.         -- finish one row
  26.         for i=1,N-1,1 do
  27.             fillUp(depth, cur_slot)
  28.             turtle.forward()
  29.         end
  30.         rows_done = rows_done + 1
  31.  
  32.         -- turn
  33.         turtle.turnLeft()
  34.         fillUp(depth, cur_slot)
  35.         turtle.forward()
  36.         turtle.turnLeft()
  37.  
  38.         -- row back
  39.         for i=1,N-1,1 do
  40.             fillUp(depth, cur_slot)
  41.             turtle.forward()
  42.         end
  43.         rows_done = rows_done + 1
  44.  
  45.         -- start a new level from current corner
  46.         if rows_done == N then
  47.             turtle.turnLeft()
  48.             rows_done = 0
  49.             level_done = true
  50.         else
  51.             turtle.turnRight()
  52.             fillUp(depth, cur_slot)
  53.             turtle.forward()
  54.             turtle.turnRight()
  55.         end
  56.     end
  57. end
  58.  
  59.  
  60.  
  61. turtle.select(1)
  62. turtle.refuel()
  63.  
  64. cur_slot = 2
  65. turtle.select(cur_slot)
  66.  
  67.  
  68.  
  69. -- N % 2 should be 0
  70. N = 4
  71. target_box_height = 2
  72.  
  73. fillSand(N, target_box_height, cur_slot)
  74.  
  75.  
  76.  
  77.  
RAW Paste Data