SHARE
TWEET

tr

a guest Feb 14th, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Turtle digger program
  2. -- version 1.1
  3. -- author mac
  4.  
  5. len = arg[1]
  6. DIG_TIMEOUT = 0.15
  7. TRASH = {
  8.   "minecraft:gravel",
  9.   "minecraft:cobblestone",
  10.   "minecraft:granite",
  11.   "minecraft:diorite",
  12.   "minecraft:andesite",
  13.   "minecraft:dirt"
  14. }
  15. fuelLevel = turtle.getFuelLevel()
  16. doDropTrash = 0
  17.  
  18. if arg[2] == "1" then
  19. doDropTrash = 1
  20. end
  21.  
  22. if len == nil then
  23.   print("Must define len by using param")
  24.   return
  25. end
  26.  
  27.  
  28. if fuelLevel < 1*len then
  29.   print("Not enough fel for that length you need a ", 5*len, "current",fuelLevel)
  30.   return
  31. end
  32.  
  33. function dropTrash()
  34.   for i = 1,16 do
  35.     a,b = turtle.getItemDetail(i)
  36.     if a ~= nil then
  37.       for block = 1,6 do
  38.         if a.name == TRASH[block] then
  39.          turtle.select(i)
  40.          turtle.dropDown()
  41.         end
  42.       end
  43.     end
  44.   end
  45.   turtle.select(1)
  46. end
  47.  
  48. function checkInventory()
  49.   while turtle.getItemCount(16) > 0 do
  50.     print("Full inventory, please clear")
  51.     sleep(10)
  52.   end
  53. end
  54.  
  55. function sdig()
  56. checkInventory()
  57. while turtle.detect() do
  58.     sleep(DIG_TIMEOUT)
  59.     turtle.dig()
  60.   end
  61. end
  62.  
  63. function sdigUp()
  64.   checkInventory()
  65.   while turtle.detectUp() do
  66.     sleep(DIG_TIMEOUT)
  67.     turtle.digUp()
  68.   end
  69. end
  70.  
  71. function digUpAndDown()
  72.   checkInventory()
  73.   sdigUp()
  74.   turtle.digDown()
  75. end
  76.  
  77.  
  78.  
  79. for i = 0,len do
  80.   print("progress ",i ," of ", len)
  81.   sdig()
  82.   turtle.forward()
  83.   digUpAndDown()
  84.  
  85.   if i % 5 == 0 and doDropTrash == 1 then
  86.     dropTrash()
  87.   end
  88. 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