SHARE
TWEET

Tree Tjop

Elec11 Mar 26th, 2020 (edited) 28 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tree
  2. local bool
  3. local y = 0
  4. local saplingCount
  5.  
  6. -- forestry:sapling_ge
  7. -- forestry:logs.0
  8. -- metadata 3
  9.  
  10. local saplingTable = {
  11.     "minecraft:sapling",
  12.     "forestry:sapling_ge",
  13.     "forestry:sapling"
  14. }
  15.  
  16. local logTable = {
  17.     "minecraft:log",
  18.     "forestry:logs.0"
  19. }
  20.  
  21. function validSapling(val)
  22.     for index, value in ipairs(saplingTable) do
  23.         if value == val then
  24.             return true
  25.         end
  26.     end
  27.  
  28.     return false
  29. end
  30.  
  31. function validLog(val)
  32.     for index, value in ipairs(logTable) do
  33.         if value == val then
  34.             return true
  35.         end
  36.     end
  37.  
  38.     return false
  39. end
  40.  
  41. while true do
  42.     print("looping")
  43.     turtle.select(1)
  44.     if turtle.getSelectedSlot(1) then
  45.         local data = turtle.getItemDetail()
  46.         if validSapling(data.name) == false then
  47.             print("no saplings found in slot 1")
  48.             return
  49.         else
  50.             saplingCount = data.count
  51.         end
  52.     end
  53.  
  54.     repeat
  55.         if turtle.detect() or turtle.place() then
  56.             pBool = true
  57.         end
  58.         print("attempting to place")
  59.     until pBool == true
  60.  
  61.     repeat
  62.         bool,tree = turtle.inspect()
  63.         print("inspecting")
  64.         os.sleep(10)
  65.     until validLog(tree.name)
  66.  
  67.     if turtle.getFuelLevel() < 10 then
  68.         print("OUT OF FUEL")
  69.         return
  70.     end
  71.  
  72.     turtle.dig()
  73.     turtle.forward()
  74.  
  75.     while turtle.detectUp() == true do
  76.         print("Chopping")
  77.         for i=1,4 do
  78.             turtle.dig()
  79.             turtle.turnLeft()
  80.         end
  81.         turtle.digUp()
  82.         turtle.up()
  83.         y = y + 1
  84.     end
  85.  
  86.     while y > 0 do
  87.         print("returning")
  88.         turtle.down()
  89.         y = y - 1
  90.     end
  91.  
  92.     turtle.back()
  93. 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