Parzival03

Untitled

Oct 17th, 2020 (edited)
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.07 KB | None | 0 0
  1. function tl (c)
  2.   for i=1, c do
  3.     turtle.turnLeft()
  4.   end
  5. end
  6.  
  7. function tr (c)
  8.   for i=1, c do
  9.     turtle.turnRight()
  10.   end
  11. end
  12.  
  13. function tun (len)
  14.   for i=1,len do
  15.     turtle.dig()
  16.     while turtle.forward() == false do turtle.dig() end
  17.     turtle.digUp()
  18.   end
  19. end
  20.  
  21. function gof (len)
  22.   for i=1, len do
  23.     while turtle.forward() == false do turtle.dig() end
  24.   end
  25. end
  26.  
  27. function fuel ()
  28.   for i=1, 16 do
  29.     turtle.select(i)
  30.     if (turtle.getItemCount(i) ~= 0 and turtle.getItemDetail(i).name ~= "minecraft:chest" and turtle.refuel(1)) then return end
  31.   end
  32. end
  33.  
  34. function cobble()
  35.   for i=1, 16 do
  36.     if (turtle.getItemCount(i) ~= 0 and turtle.getItemDetail(i).name == "minecraft:cobblestone") then
  37.       turtle.select(i)
  38.       turtle.drop()
  39.     end
  40.   end
  41.   turtle.select(1)
  42. end
  43.  
  44. function dirt()
  45.   for i=1, 16 do
  46.     if (turtle.getItemCount(i) ~= 0 and turtle.getItemDetail(i).name == "minecraft:dirt") then
  47.       turtle.select(i)
  48.       turtle.drop()
  49.     end
  50.   end
  51.   turtle.select(1)
  52. end
  53.  
  54. function inv()
  55.   total = 0
  56.   for i=1, 16 do
  57.     if turtle.getItemCount(i) ~= 0 then
  58.       total=total+1
  59.     end
  60.   end
  61.   return total
  62. end
  63.  
  64. function chest()
  65.   chestPlaced = false
  66.   for i=1, 16 do
  67.     if (turtle.getItemCount(i) ~= 0 and turtle.getItemDetail(i).name == "minecraft:chest") then
  68.       turtle.digDown()
  69.       turtle.select(i)
  70.       turtle.placeDown()
  71.       chestPlaced = true
  72.     end
  73.   end
  74.  
  75.   if chestPlaced then
  76.     print("Placed Chest")
  77.     for i=1, 16 do
  78.       if (turtle.getItemCount(i) ~= 0 and turtle.getItemDetail(i).name ~= "minecraft:chest") then
  79.         turtle.select(i)
  80.         turtle.dropDown()
  81.       end
  82.     end
  83.   end
  84.  
  85.   return chestPlaced
  86. end
  87.  
  88. while true do
  89.   -- Refuel, clear inventory
  90.   fuel()
  91.   cobble()
  92.   dirt()
  93.  
  94.   -- Strip mining algorithm
  95.   tun(3)
  96.   tl(1)
  97.   tun(7)
  98.   tl(2)
  99.   gof(7)
  100.   tun(7)
  101.   tl(2)
  102.   gof(7)
  103.   tr(1)
  104.  
  105.   -- Inventory Check
  106.   if inv() == 16 then
  107.     print("Invetory Full")
  108.     if chest() == false then
  109.       print("No Chests. Stopping.")
  110.       break
  111.     end
  112.   end
  113.  
  114.  
  115. end
  116.  
Add Comment
Please, Sign In to add comment