ReakThor

SimpleTurtleMiner

Jan 18th, 2022 (edited)
640
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Refuel()
  2.     textutils.slowPrint("Refueling...")
  3.     local i_lavaFuel = 1000
  4.     local i_coalFuel = 80
  5.     local i_coalBlockFuel = 800
  6.    
  7.     local travelable = 0
  8.    
  9.     for i = 1,16 do
  10.         turtle.select(i)
  11.         if turtle.refuel(0) then
  12.             local item = turtle.getItemDetail()
  13.             if item.name == "minecraft:lava_bucket" then
  14.                 travelable = travelable + (item.count * i_lavaFuel)
  15.             elseif item.name == "minecraft:coal" or item.name == "minecraft:charcoal" then
  16.                 travelable = travelable + (item.count * i_coalFuel)
  17.             elseif item.name == "minecraft:coal_block" or item.name == "minecraft:charcoal_block" then
  18.                 travelable = travelable + (item.count * i_coalBlockFuel)
  19.             else
  20.                 travelable = travelable + 1
  21.             end
  22.         end
  23.         turtle.refuel()
  24.     end
  25. turtle.select(1)
  26. print("Refueled for: " .. travelable)
  27. end
  28.  
  29. function CalculateFuelUsage(required)
  30.     if turtle.getFuelLevel() >= required then
  31.         textutils.slowPrint("Mining...\nPlease wait!")
  32.         return true
  33.     end
  34.     print("Need " .. (required-turtle.getFuelLevel()) .. "fuel!")
  35.     return false
  36. end
  37.  
  38. function MineFORWARD_Move()
  39.     while turtle.detect() do
  40.         turtle.dig()
  41.     end
  42.     turtle.forward()
  43. end
  44.  
  45. function MineUP()
  46.     while turtle.detectUp() do
  47.         turtle.digUp()
  48.     end
  49. end
  50.  
  51. function MineLEFT_Move()
  52.     turtle.turnLeft()
  53.     MineUF_Move()
  54. end
  55.  
  56. function MineRIGHT_Move()
  57.     turtle.turnRight()
  58.     MineUF_Move()
  59. end
  60.  
  61. function MineUF_Move()
  62.     MineUP()
  63.     MineFORWARD_Move()
  64. end
  65.  
  66. function SimpleMineL(forward, sideways)
  67.     Refuel()
  68.     if CalculateFuelUsage(((2 * 3) + (2 * forward) * sideways) + 3 * sideways) then
  69.         turtle.turnLeft()
  70.         for i=1,sideways do
  71.             for j=1,3 do
  72.                 MineUF_Move()
  73.             end
  74.             for k=1,2 do
  75.                 turtle.turnRight()
  76.                 for l=1,forward do
  77.                     MineUF_Move()
  78.                 end
  79.                 turtle.turnRight()
  80.                 for m=1,3 do
  81.                 MineUF_Move()
  82.                 end
  83.             end
  84.         end
  85.         turtle.turnLeft()
  86.         turtle.turnLeft()
  87.         for i=1,(sideways * 3) do
  88.             turtle.forward()
  89.         end
  90.         turtle.turnLeft()
  91.     else
  92.         print("Not enough fuel in inventory!")
  93.     end
  94. end
  95.  
  96. function SimpleMineR(forward, sideways)
  97.     Refuel()
  98.     if CalculateFuelUsage(turtle.getFuelLevel(),((2 * 3) + (2 * forward) * sideways) + 3 * sideways) then
  99.         turtle.turnRight()
  100.         for i=1,sideways do
  101.             for j=1,3 do
  102.                 MineUF_Move()
  103.             end
  104.             for k=1,2 do
  105.                 turtle.turnLeft()
  106.                 for l=1,forward do
  107.                     MineUF_Move()
  108.                 end
  109.                 turtle.turnLeft()
  110.                 for m=1,3 do
  111.                 MineUF_Move()
  112.                 end
  113.             end
  114.         end
  115.         turtle.turnRight()
  116.         turtle.turnRight()
  117.         for i=1,(sideways * 3) do
  118.             turtle.forward()
  119.         end
  120.         turtle.turnRight()
  121.     else
  122.         print("Not enough fuel in inventory!")
  123.     end
  124. end
  125.  
  126. print("forward | :")
  127. f = read()
  128. print("sideways - :")
  129. s = read()
  130. SimpleMineL(f,s)
  131. SimpleMineR(f,s)
RAW Paste Data Copied