SHARE
TWEET

Untitled

Proaxel May 25th, 2020 (edited) 1,205 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. args = {...}
  2. dist = args[1]
  3. run = true
  4. torchDistance = 0
  5. currentDistance = 0
  6.  
  7. turtle.select(14)
  8. turtle.refuel()
  9. turtle.select(1)
  10.  
  11. print("Welcome! Current fuel: ", turtle.getFuelLevel())
  12. print("Enter the distance as an integer...")
  13. maxDistance = io.read()
  14. maxDistance = tonumber(maxDistance)
  15. print("Enter torch distance as an integer...")
  16. maxTorchDistance = io.read()
  17. maxTorchDistance = tonumber(maxTorchDistance)
  18.  
  19. if turtle.getFuelLevel() < maxDistance then
  20.     print("WARNING: turtle does not have the fuel to move the entire distance required")
  21. end
  22.  
  23. print("Starting mine")
  24.  
  25. while run do
  26.     if turtle.getFuelLevel() <= 0 then
  27.         print("NO FUEL. Stopping.")
  28.         break
  29.     end
  30.     print("Distance: " , currentDistance)
  31.     print("TorchDistance: " , torchDistance)
  32.    
  33.     print("Dig front side")
  34.     turtle.dig()
  35.     turtle.digUp()
  36.     turtle.digDown()
  37.    
  38.     print("Dig right side")
  39.     turtle.turnRight()
  40.     turtle.dig()
  41.     turtle.forward()
  42.     turtle.digUp()
  43.     turtle.digDown()
  44.     turtle.back()
  45.     if turtle.getItemCount(15) > 0 then
  46.         if torchDistance >= maxTorchDistance then
  47.             print("Setting Torch")
  48.             turtle.select(15)
  49.             turtle.place()
  50.             turtle.select(1)
  51.             torchDistance = 0
  52.         else
  53.             print("Not placing torch. " , torchDistance , "<" , maxTorchDistance)
  54.         end
  55.     else
  56.         print("Warning: No torches!!")
  57.     end
  58.     turtle.turnLeft()
  59.    
  60.     print("Dig left side")
  61.     turtle.turnLeft()
  62.     turtle.dig()
  63.     turtle.forward()
  64.     turtle.digUp()
  65.     turtle.digDown()
  66.     turtle.back()
  67.     turtle.turnRight()
  68.    
  69.     if turtle.getItemCount(13) > 0 then
  70.         print("nearly full, chest dumping")
  71.         turtle.select(16)
  72.         turtle.placeDown()
  73.         for a = 1, 14 do
  74.             turtle.select(a)
  75.             turtle.dropDown()
  76.         end
  77.         if turtle.getItemCount(16) < 0 then
  78.             print("Out of chests!! Stopping")
  79.             break
  80.         end
  81.         turtle.select(1)
  82.     end
  83.    
  84.     turtle.forward()
  85.     currentDistance = currentDistance + 1
  86.     torchDistance = torchDistance + 1
  87.    
  88.     if currentDistance >= maxDistance then
  89.         print("Max distance of " , maxDistance , " reached. Stopping")
  90.         run = false    
  91.     end
  92. end
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