Advertisement
Lyandro

oxidizedCopper

Oct 3rd, 2022 (edited)
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.31 KB | Source Code | 0 0
  1. local numLinhas = 5
  2. local indiceColuna = 0
  3. local distBlocos = 5
  4. local slotCount = 16
  5. local isBlock, data, isCobble, data1, itemDrop
  6.  
  7. function moveBlocks()
  8.  
  9.     for i = 1, distBlocos, 1 do
  10.         turtle.forward()
  11.     end
  12.  
  13. end
  14.  
  15. function moveLine()
  16.  
  17.     for i = 1, numLinhas - 1, 1 do
  18.         moveBlocks()
  19.         swapDirection()
  20.         colectOxidizedCopper()
  21.     end
  22.  
  23. end
  24.  
  25. function swapDirection()
  26.  
  27.     if (indiceColuna % 2 == 0) then
  28.         turtle.turnLeft()
  29.     else
  30.         turtle.turnRight()
  31.     end
  32.  
  33. end
  34.  
  35. function invertedSwapDirection()
  36.  
  37.     if (indiceColuna % 2 == 0) then
  38.         turtle.turnRight()
  39.     else
  40.         turtle.turnLeft()
  41.     end
  42.  
  43. end
  44.  
  45. function getItemIndex(itemName)
  46.  
  47.     for slot = 1, slotCount, 1 do
  48.         local item = turtle.getItemDetail(slot)
  49.         if (item ~= nil) then
  50.             if (item["name"] == itemName) then
  51.                 return slot
  52.             end
  53.         end
  54.     end
  55. end
  56.  
  57. function verifyItemExist(itemName)
  58.  
  59.     for slot = 1, slotCount, 1 do
  60.         local item = turtle.getItemDetail(slot)
  61.         if (item ~= nil) then
  62.             if (item["name"] == itemName) then
  63.                 return true
  64.             end
  65.         else
  66.             return false
  67.         end
  68.     end
  69. end
  70.  
  71. function placeCopperBlock()
  72.  
  73.     local copBlockExist = verifyItemExist("minecraft:copper_block")
  74.     if (copBlockExist) then
  75.         local copperBlockIndex = getItemIndex("minecraft:copper_block")
  76.         turtle.select(copperBlockIndex)
  77.         turtle.place()
  78.     end
  79.  
  80. end
  81.  
  82. function colectOxidizedCopper()
  83.  
  84.     isBlock, data = turtle.inspect()
  85.  
  86.     if (isBlock) then
  87.         if (indiceColuna % 2 == 0) then
  88.             if (data.name == "minecraft:oxidized_copper") then
  89.                 turtle.dig()
  90.                 placeCopperBlock()
  91.                 turtle.turnRight()
  92.             else
  93.                 turtle.turnRight()
  94.             end
  95.         else
  96.             if (data.name == "minecraft:oxidized_copper") then
  97.                 turtle.dig()
  98.                 placeCopperBlock()
  99.                 turtle.turnLeft()
  100.             else
  101.                 turtle.turnLeft()
  102.             end
  103.         end
  104.     else
  105.         if (indiceColuna % 2 == 0) then
  106.             placeCopperBlock()
  107.             turtle.turnRight()
  108.         else
  109.             placeCopperBlock()
  110.             turtle.turnLeft()
  111.         end
  112.     end
  113.  
  114. end
  115.  
  116. invertedSwapDirection()
  117.  
  118. while true do
  119.  
  120.     invertedSwapDirection()
  121.     turtle.forward()
  122.     swapDirection()
  123.     colectOxidizedCopper()
  124.  
  125.     moveLine()
  126.     turtle.forward()
  127.  
  128.     isCobble, data1 = turtle.inspect()
  129.     if (isCobble) then
  130.         if (data1.name == "minecraft:cobblestone") then
  131.             invertedSwapDirection()
  132.             for i = 1, 15, 1 do
  133.                 turtle.forward()
  134.             end
  135.             swapDirection()
  136.             local oxiCopBlockExist = verifyItemExist("minecraft:oxidized_copper")
  137.             if (oxiCopBlockExist) then
  138.                 itemDrop = getItemIndex("minecraft:oxidized_copper")
  139.                 turtle.select(itemDrop)
  140.                 turtle.drop()
  141.             end
  142.             swapDirection()
  143.             indiceColuna = 0
  144.             sleep(900)
  145.         end
  146.     else
  147.         swapDirection()
  148.         moveBlocks()
  149.         indiceColuna = indiceColuna + 1
  150.     end
  151.  
  152. end
  153.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement