rl2014

tree.lua

May 19th, 2021 (edited)
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. if not turtle then
  2.     return error("Only avialable for turtles.")
  3. end
  4.  
  5. local tree = {}
  6.  
  7. function tree.cut(config)
  8.     local z = 0
  9.     turtle.select(config.log)
  10.     while(turtle.compare()) do
  11.         turtle.dig()
  12.         turtle.select(config.leaf)
  13.         if(turtle.compareUp()
  14.             or not turtle.inspectUp()) then
  15.             turtle.digUp()
  16.             turtle.up()
  17.             z = z + 1
  18.         end
  19.         turtle.select(config.log)
  20.     end
  21.     for _ = z, 0, -1 do
  22.         turtle.down()
  23.     end
  24. end
  25.  
  26. function tree.plant(config)
  27.     turtle.select(config.sapling)
  28.     turtle.place()
  29. end
  30.  
  31. return tree
Add Comment
Please, Sign In to add comment