donovanwest

livingRock.lua

Jun 28th, 2022 (edited)
977
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getItemById(id)
  2.     for slot = 1, 16, 1 do
  3.         item = turtle.getItemDetail(slot)
  4.         if item ~= nil and item.name == id then
  5.             return slot
  6.         end
  7.     end
  8.     return nil
  9. end
  10.  
  11. function checkFuel()
  12.     if turtle.getFuelLevel() < 160 then
  13.         turtle.suckDown()
  14.         for slot = 1, 16, 1 do
  15.             turtle.select(slot)
  16.             turtle.refuel()
  17.         end
  18.     end
  19. end
  20.  
  21. function selectItem()
  22.     stone = getItemById("minecraft:stone")
  23.     log = getItemById("minecraft:oak_log")    
  24.     if(stone ~= nil) then
  25.         turtle.select(stone)
  26.     end
  27.     if(log ~= nil) then
  28.         turtle.select(log)
  29.     end
  30.     if((stone == nil and log == nil) or (turtle.getItemCount() < 8)) then
  31.         turtle.turnLeft()
  32.         turtle.suck()
  33.         turtle.turnRight()
  34.         selectItem()
  35.     end
  36. end
  37.  
  38. function advanceAndDig()
  39.     turtle.forward()
  40.     turtle.digDown()
  41.     turtle.placeDown()
  42. end
  43.  
  44. function dump(id)
  45.     turtle.turnRight()
  46.     while(getItemById(id)) do
  47.         turtle.select(getItemById(id))
  48.         turtle.drop()
  49.     end
  50.     turtle.turnLeft()
  51. end
  52.  
  53. while(true) do
  54.     checkFuel()
  55.     selectItem()
  56.     advanceAndDig()
  57.     turtle.turnLeft()
  58.     advanceAndDig()
  59.     turtle.turnRight()
  60.     advanceAndDig()
  61.     advanceAndDig()
  62.     turtle.turnRight()
  63.     advanceAndDig()
  64.     advanceAndDig()
  65.     turtle.turnRight()
  66.     advanceAndDig()
  67.     advanceAndDig()
  68.     turtle.turnRight()
  69.     turtle.forward()
  70.     turtle.turnRight()
  71.     turtle.back()
  72.     dump("botania:livingwood")
  73.     dump("botania:livingrock")
  74.     os.sleep(70)
  75. end
RAW Paste Data Copied