Bollie

Simplest Treechopper

May 9th, 2021 (edited)
890
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- http://pastebin.com/hyKTwW2Y
  2. -- http://pastebin.com/u/Bollie
  3. os.loadAPI("p") -- http://pastebin.com/SGcYmCqd
  4. os.loadAPI("t") -- http://pastebin.com/6vxbgdjX
  5.  
  6. -- READ PARAMETERS
  7. local args = { ... }
  8.  
  9. if #args > 0 then
  10.  p.send("usage: no arguments")
  11. end
  12. p.send("Place sapplings in slot 15")
  13. p.send("Waiting for tree to grow")
  14.  
  15. t.loadblocks()
  16.  
  17. function fuelCheck()
  18.   local fuelLevel = t.getFuelLevel()
  19.   if fuelLevel < 100 then
  20.     chopping = false
  21.   end
  22. end
  23.  
  24. -- IsLogBlock
  25. function isLogBlock(fnInspect)
  26.  local logblocks = {
  27.    "minecraft:spruce_log"
  28.  , "minecraft:birch_log"
  29.  , "minecraft:oak_log"
  30.  , "terrestria:redwood_log"
  31.  , "terrestria:hemlock_log"
  32.  , "traverse:fir_log"
  33. }
  34.  local success, data = fnInspect()
  35.  local i
  36.  
  37.  if (success) then
  38.   for _, v in ipairs(logblocks) do
  39.    if data.name == v then
  40.     return true
  41.    end
  42.   end
  43.  end
  44.  return false
  45. end
  46.  
  47. function chopTree()
  48.   if isLogBlock(t.inspect) then
  49.     print("Tree detected... chopping.")
  50.     t.digAndForward()
  51.     while isLogBlock(t.inspectUp) == true do
  52.       t.digAndUp()
  53.     end
  54.     while t.detectDown() == false do
  55.       t.down()
  56.     end
  57.     t.back()
  58.     t.select(15)
  59.     t.place()
  60.     t.select(1)
  61.   end
  62. end
  63.  
  64. local chopping = true
  65. while chopping do
  66.   fuelCheck()
  67.   chopTree()
  68.   t.suck()
  69.   t.suckUp()
  70.   t.saveblocks()
  71. end
RAW Paste Data