SHARE
TWEET

ValuableFinderv1

Proaxel May 28th, 2020 (edited) 1,443 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. depth = 0
  2. descending = true
  3.  
  4. function fuel()
  5.     if turtle.getFuelLevel() <= 10 then
  6.         turtle.select(16)
  7.         turtle.refuel()
  8.     end
  9. end
  10.  
  11. function isValuable()
  12.     local junkTable = {"minecraft:stone", "minecraft:dirt", "minecraft:gravel", "minecraft:sand", "minecraft:torch"}
  13.     local valuable = true
  14.    
  15.     local isBlock, blockData = turtle.inspect()
  16.         if isBlock == true then
  17.             print("There's something here. Block data:")
  18.             print(blockData.name)
  19.             print(blockData.metadata)
  20.             for k, v in ipairs(junkTable) do
  21.                 if blockData.name == v then
  22.                     print("This is junk.")
  23.                     valuable = false
  24.                     break
  25.                 end
  26.             end
  27.         else
  28.             print("There isn't anything here.")
  29.             valuable = false
  30.         end
  31.     if valuable then
  32.         print("There's something valuable here!")
  33.         return true
  34.        
  35.     else
  36.         print("Nothing interesting here. Moving on")
  37.         return false
  38.     end
  39. end
  40.  
  41. function checkSides()
  42.     for i = 0, 3, 1 do
  43.         if isValuable() then
  44.             turtle.dig()
  45.         end
  46.         turtle.turnRight()
  47.     end
  48. end
  49.  
  50. function isBottomEmpty()
  51.     local isBlock, blockData = turtle.inspect()
  52.     if isBlock then
  53.         return true
  54.     else
  55.         return false
  56.     end
  57. end
  58.  
  59. function isBottomBedrock()
  60.     local isBlock, blockData = turtle.inspectDown()
  61.     if isBlock then
  62.         if blockData.name == "minecraft:bedrock" then
  63.             print("We've hit bedrock!")
  64.             return true
  65.         else
  66.             return false
  67.         end
  68.     else
  69.         return false
  70.     end
  71. end
  72.  
  73.  
  74. print("Let's go!")
  75.  
  76.  
  77. while descending do
  78.     fuel()
  79.     checkSides()
  80.     if isBottomBedrock() then
  81.         descending = false
  82.         break
  83.     end
  84.     turtle.digDown()
  85.     turtle.down()
  86.     depth = depth + 1
  87. end
  88.  
  89. print("Let's go back up...")
  90.  
  91. while depth ~= 0 do
  92.     fuel()
  93.     if turtle.up() then
  94.         depth = depth - 1
  95.     else
  96.         print("Obstruction detected...")
  97.         turtle.digUp()
  98.     end
  99. end
  100.  
  101. print("Done!")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top