Hopfi

underwater_support_level

May 15th, 2021
919
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function checkBlockCapacity(cur_slot, N)
  2.     -- check if there is enough cobble, otherwise
  3.     if turtle.getItemCount() <= N * N 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.  
  15. function buildLevel(cur_slots, N)
  16.     level_done = false
  17.     rows_done = 0
  18.     while not level_done do
  19.  
  20.         is_inv_emtpy = checkBlockCapacity(cur_slot, N)
  21.  
  22.         if is_inv_empty then
  23.             -- go back and get more blocks..
  24.         end
  25.  
  26.         -- finish one row
  27.         for i=1,N-1,1 do
  28.             turtle.placeDown()
  29.             turtle.forward()
  30.         end
  31.         rows_done = rows_done + 1
  32.  
  33.         -- turn
  34.         turtle.turnLeft()
  35.         turtle.placeDown()
  36.         turtle.forward()
  37.         turtle.turnLeft()
  38.  
  39.         -- row back
  40.         for i=1,N-1,1 do
  41.             turtle.placeDown()
  42.             turtle.forward()
  43.         end
  44.         rows_done = rows_done + 1
  45.  
  46.         -- start a new level from current corner
  47.         if rows_done == N then
  48.             turtle.turnLeft()
  49.             turtle.placeDown()
  50.             rows_done = 0
  51.             level_done = true
  52.         else
  53.             turtle.turnRight()
  54.             turtle.placeDown()
  55.             turtle.forward()
  56.             turtle.turnRight()
  57.         end
  58.     end
  59. end
  60.  
  61. turtle.select(1)
  62. turtle.refuel()
  63.  
  64. cur_slot = 2
  65. turtle.select(cur_slot)
  66.  
  67. -- wanted height of box
  68. box_height = 0
  69.  
  70. -- wanted side length of box
  71. N = 4
  72.  
  73. -- go down to start depth = free water spaces above final built box
  74. start_depth = 2
  75. for i=1, start_depth, 1 do
  76.     turtle.down()
  77. end
  78.  
  79. buildLevel(cur_slot, N)
  80.  
  81. for i=1, start_depth, 1 do
  82.     turtle.up()
  83. end
  84.  
  85.  
  86.  
RAW Paste Data