HappySunChild

spiral

Jul 6th, 2026
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. local c_args = { ... }
  2.  
  3. local target_depth = tonumber(c_args[1])
  4.  
  5. local function find_item()
  6.     for slot_index = 1, 16 do
  7.         if turtle.getItemCount(slot_index) > 0 then
  8.             return slot_index
  9.         end
  10.     end
  11.  
  12.     return -1
  13. end
  14.  
  15. local function try_place_down()
  16.     if not turtle.placeDown() then
  17.         local slot = find_item()
  18.  
  19.         if slot == -1 then
  20.             error("can't place, out of blocks")
  21.         end
  22.  
  23.         turtle.select(slot)
  24.  
  25.         try_place_down()
  26.     end
  27. end
  28.  
  29. for i = 1, target_depth do
  30.     try_place_down()
  31.     turtle.forward()
  32.     turtle.down()
  33.    
  34.     if i % 10 == 0 then
  35.         turtle.turnRight()
  36.     end
  37. end
  38.  
Advertisement
Add Comment
Please, Sign In to add comment