mpaul97

platform

Aug 7th, 2021 (edited)
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. local dim = read()
  2.  
  3. turtle.select(1)
  4.  
  5. local detail = turtle.getItemDetail()
  6.  
  7. local count = 1
  8.  
  9. local notEmptyCount = 0
  10.  
  11. function digBlock()
  12.     if turtle.detect() then
  13.         turtle.dig()
  14.     end
  15. end
  16.  
  17. function allEmpty()
  18.     isEmpty = false
  19.     for i = 1, 16, 1 do
  20.         turtle.select(i)
  21.         if turtle.getItemDetail() ~= nil then
  22.             if turtle.getItemCount() ~= 0 then
  23.                 if turtle.getItemDetail().name == detail.name then
  24.                     notEmptyCount = notEmptyCount + 1
  25.                 end
  26.             end
  27.         end
  28.     end
  29.     if notEmptyCount == 0 then
  30.         isEmpty = true
  31.     end
  32.     return isEmpty
  33. end
  34.                    
  35.  
  36. for j = 0, dim-1, 1 do
  37.     for i = 0, dim-1, 1 do
  38.         digBlock()
  39.         turtle.forward()
  40.         turtle.turnRight()
  41.         turtle.turnRight()
  42.             if turtle.getItemCount() == 0 or turtle.getItemDetail().name ~= detail.name then
  43.                 for k = 1, 16, 1 do
  44.                     turtle.select(k)
  45.                     if turtle.getItemDetail() ~= nil then
  46.                         if turtle.getItemDetail().name == detail.name then
  47.                             count = k
  48.                             break
  49.                         end
  50.                     end
  51.                 end
  52.             end
  53.         turtle.select(count)
  54.         turtle.place()
  55.         turtle.turnRight()
  56.         turtle.turnRight()
  57.     end
  58.     digBlock()
  59.     if j % 2 == 0 then
  60.         turtle.turnRight()
  61.         digBlock()
  62.         turtle.forward()
  63.         turtle.turnRight()
  64.         digBlock()
  65.         turtle.forward()
  66.     else
  67.         turtle.turnLeft()
  68.         digBlock()
  69.         turtle.forward()
  70.         turtle.turnLeft()
  71.         digBlock()
  72.         turtle.forward()
  73.     end
  74. end
Add Comment
Please, Sign In to add comment