Advertisement
kovakovi2000

CC: lining up 2

Feb 14th, 2021 (edited)
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.85 KB | None | 0 0
  1. local args = {...}
  2. if args[1] == nil then
  3.     error("No Arg found")
  4. end
  5. local GoUntile = 72
  6.  
  7. local function collect()
  8.     for n=1,16 do
  9.         local nCount = turtle.getItemCount(n)
  10.         if nCount > 0 then
  11.             turtle.select(n)          
  12.             turtle.dropDown()
  13.         end
  14.     end
  15. end
  16.  
  17. function IsStone()
  18.     success, data = turtle.inspectUp()
  19.     if not success then
  20.         return false
  21.     end
  22.     if data.name == "minecraft:stone" or data.name == "minecraft:cobblestone" then
  23.         return true
  24.     end
  25.     return false
  26. end
  27.  
  28.  
  29. function IsTurtle()
  30.     success, data = turtle.inspect()
  31.     if not success then
  32.         return false
  33.     end
  34.     if data.name == "computercraft:turtle_advanced" then
  35.         return true
  36.     end
  37.     return false
  38. end
  39.  
  40. function IsEnderChest()
  41.     success, data = turtle.inspectDown()
  42.     if not success then
  43.         return false
  44.     end
  45.     if data.name == "enderstorage:ender_storage" then
  46.         return true
  47.     end
  48.     return false
  49. end
  50.  
  51. local serial = tonumber( args[1] )
  52. local ize = tonumber(string.format("%.0f", (serial - 1) / 16 - 0.5))
  53. if ize < 0 then
  54.     ize = 0
  55. end
  56. local forward = 14 - ize * 2
  57. local fo = forward
  58. local left = 16 - (serial - (ize * 16))
  59. local le = left
  60. print("Forward="  .. forward .. " | left=" .. left)
  61. x, y, z = gps.locate(5)
  62.  
  63. while forward ~= 0 do
  64.     if turtle.detect() then
  65.         if not IsTurtle() then
  66.             turtle.dig()
  67.         end
  68.     end
  69.     if turtle.forward() then
  70.         forward = forward - 1
  71.     end
  72. end
  73.  
  74. turtle.turnLeft()
  75.  
  76. while left ~= 0 do
  77.     if turtle.detect() then
  78.         if not IsTurtle() then
  79.             turtle.dig()
  80.         end
  81.     end
  82.     if turtle.forward() then
  83.         left = left - 1
  84.     end
  85. end
  86. turtle.turnRight()
  87. ---------------------------------
  88. turtle.dig()
  89. turtle.digDown()
  90. local depth = y
  91. while depth ~= GoUntile do
  92.     if turtle.down() then
  93.         depth = depth - 1
  94.     else
  95.         turtle.attackDown()
  96.     end
  97.     turtle.digDown()
  98.     turtle.dig()
  99. end
  100.  
  101. while depth ~= y do
  102.     if turtle.up() then
  103.         depth = depth + 1
  104.     else
  105.         if IsStone() then
  106.             turtle.digUp()
  107.         else
  108.             turtle.attackUp()
  109.         end
  110.     end
  111. end
  112. ----------------------------------
  113. forward = 15 - fo
  114. while forward ~= 0 do
  115.     if turtle.forward() then
  116.         forward = forward - 1
  117.     end
  118. end
  119.  
  120. turtle.turnRight()
  121.  
  122. left = le
  123. while left ~= 0 do
  124.     if turtle.forward() then
  125.         left = left - 1
  126.     end
  127. end
  128. turtle.turnRight()
  129.  
  130. depth = 2
  131. while depth ~= 0 do
  132.     if turtle.up() then
  133.         depth = depth - 1
  134.     end
  135. end
  136.  
  137. forward = 14
  138. while forward ~= 0 do
  139.     if turtle.forward() then
  140.         forward = forward - 1
  141.     else
  142.         if IsEnderChest() then
  143.             collect()
  144.         end
  145.     end
  146. end
  147.  
  148. while not IsEnderChest() do end
  149. collect()
  150.  
  151. forward = 1
  152. while forward ~= 0 do
  153.     if turtle.forward() then
  154.         forward = forward - 1
  155.     end
  156. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement