amsarge

Mine_Test 1.0

May 5th, 2022 (edited)
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.42 KB | None | 0 0
  1. local SLOT_COUNT = 16
  2. local d = "north"
  3. local width, depth, height = 10, 10, 1
  4. local x = 0
  5.  
  6. if (#arg == 2) then
  7.     width = tonumber(arg[1])
  8.     depth = tonumber(arg[2])
  9.   else
  10.     print('No arguments given using defaults 10 x 10') -- asks for number input
  11. end
  12.  
  13. depth = depth + 1
  14.  
  15.  
  16. DROPPED_ITEMS = { -- Gets items to drop
  17.     "minecraft:stone",
  18.     "minecraft:dirt",
  19.     "minecraft:cobblestone",
  20.     "minecraft:diorite",
  21.     "minecraft:andesite",
  22.     "minecraft:granite",
  23.     "minecraft:sand",
  24.     "minecraft:gravel",
  25.     "minecraft:redstone",
  26.     "minecraft:lapis_lazuli",
  27.     "minecraft:flint",
  28.     "railcraft:ore_metal",
  29.     "extrautils2:ingredients",
  30.     "minecraft:dye",
  31.     "thaumcraft:nugget",
  32.     "thaumcraft:crystal_essence",
  33.     "thermalfoundation:material",
  34.     "projectred-core:resource_item",
  35.     "thaumcraft:ore_cinnabar",
  36.     "deepresonance:resonating_ore",
  37.     "forestry:apatite",
  38.     "quark:jasper",
  39.     "quark:cobbled_deepslate",
  40.     "create:gabbro_cobblestone",
  41.     "create:scoria",
  42.     "create:scoria_cobblestone",
  43.     "quark:slate",
  44.     "undergarden:deepsoil",
  45.     "undergarden:depthrock",
  46.     "quark:marble",
  47.     "astralsorcery:marble_raw",
  48.     "create:limestone_cobblestone",
  49.     "create:weathered_limestone_cobblestone",
  50.     "emendatusenigmatica:fluorite_gem",
  51.     "extcaves:lavastone",
  52.     "thermal:cinnabar",
  53.  
  54.  
  55. }
  56. function dropItems() -- drops items
  57.     print("Purging Inventory...")
  58.     for slot = 1, SLOT_COUNT, 1 do
  59.         local item = turtle.getItemDetail(slot) --gets details on item, if it's = to items to drop it will drop items
  60.         if(item ~= nil) then
  61.             for filterIndex = 1, #DROPPED_ITEMS, 1 do
  62.                 if(item["name"] == DROPPED_ITEMS[filterIndex]) then
  63.                     print("Dropping - " .. item["name"])
  64.                     turtle.select(slot)
  65.                     turtle.dropDown()
  66.                 end
  67.             end
  68.         end
  69.     end
  70. end
  71.  
  72. function manageInventory()
  73.   dropItems()
  74.   turtle.digUp()
  75.   turtle.digDown()
  76. end
  77.  
  78. function checkFuel()
  79.     turtle.select(1)
  80.  
  81.     if(turtle.getFuelLevel() < 50) then
  82.         print("Attempting Refuel...")
  83.         for slot = 1, SLOT_COUNT, 1 do
  84.             turtle.select(slot)
  85.             if(turtle.refuel(1)) then
  86.                 return true
  87.             end
  88.         end
  89.  
  90.         return false
  91.     else
  92.         return true
  93.     end
  94. end
  95.  
  96. function DigUp()
  97.     while(turtle.detectUp()) do
  98.       turtle.digUp()
  99.       turtle.digDown()
  100.       turtle.dig()
  101.  
  102.   end
  103. end
  104.  
  105. function DigDown()
  106.   while(turtle.detectDown()) do
  107.     turtle.digUp()
  108.     turtle.digDown()
  109.     turtle.dig()
  110.  
  111.   end
  112. end
  113.  
  114. function Dig()
  115.     while(turtle.detect()) do
  116.         turtle.digUp()
  117.         turtle.digDown()
  118.         turtle.dig()
  119.  
  120.     end
  121.   end
  122.  
  123.   function detectAndDig()
  124.     Dig()
  125.     DigDown()
  126.     DigUp()
  127.   end
  128.  
  129.  
  130.   function forward()
  131.     detectAndDig()
  132.     turtle.forward()
  133.   end
  134.  
  135.  
  136. function rightTurn()
  137.   turtle.turnRight()
  138.   detectAndDig()
  139.   turtle.forward()
  140.   turtle.turnRight()
  141.   detectAndDig()
  142. end
  143.  
  144.  
  145. function leftTurn()
  146.   turtle.turnLeft()
  147.   detectAndDig()
  148.   turtle.forward()
  149.   turtle.turnLeft()
  150.   detectAndDig()
  151. end
  152.  
  153. function flipDirection()
  154.     if(d == "north") then
  155.         d = "south"
  156.     elseif(d == "south") then
  157.         d = "north"
  158.     elseif(d == "west") then
  159.         d = "east"
  160.     elseif(d == "east") then
  161.         d = "west"
  162.     end
  163.  
  164. end
  165.  
  166. function turnAround(tier)
  167.     if(tier % 2 == 1) then
  168.         if(d == "north" or d == "east") then
  169.             rightTurn()
  170.         elseif(d == "south" or d == "west") then
  171.             leftTurn()
  172.         end
  173.     else
  174.         if(d == "north" or d == "east") then
  175.             leftTurn()
  176.         elseif(d == "south" or d == "west") then
  177.             rightTurn()
  178.         end
  179.     end
  180.     flipDirection()
  181. end
  182.  
  183. function start() --Function order loop
  184.     for tier = 1, height, 1 do
  185.         for col = 1, width, 1 do
  186.             for row = 1, depth - 1, 1 do
  187.                 if(not checkFuel()) then
  188.                     print("Turtle is out of fuel, Powering Down...")
  189.                     return
  190.                 end
  191.                 forward()
  192.                 print(string.format("Row: %d   Col: %d", row, col))
  193.             end
  194.             if(col ~= width) then
  195.                 turnAround(tier)
  196.                 x = x + 1
  197.             end
  198.               manageInventory()
  199.             end
  200.  
  201.         end
  202.  
  203.     end
  204.  
  205. start()
  206.  
Add Comment
Please, Sign In to add comment