Advertisement
Guest User

tt

a guest
Jan 17th, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.67 KB | None | 0 0
  1. ignore={["minecraft:grass"] = true,["minecraft:dirt"] = true,["minecraft:stone"] = true,["minecraft:cobblestone"] = true,["minecraft:gravel"] = true,["minecraft:sand"] = true}
  2. wood={["MineFactoryReloaded:rubberwood.log"] = true,["minecraft:log"] = true,["Natura:Rare Tree"] = true}
  3. height = 0
  4. direction = 1
  5. top = 0
  6. --Move Functions--
  7.  
  8.  
  9. function tl()
  10.   turtle.turnLeft()
  11. end
  12.  
  13. function tr()
  14.   turtle.turnRight()
  15. end
  16.  
  17. function tf()
  18.   while not turtle.forward() do
  19.     turtle.attack()
  20.   end
  21. end
  22.  
  23. function td()
  24.   while not turtle.down() do
  25.     turtle.attackDown()  
  26.   end
  27. end
  28.  
  29. function tu()
  30.   while not turtle.up() do
  31.     turtle.attackUp()  
  32.   end
  33. end
  34.  
  35.  
  36. --Block Inspect Functions--
  37.  
  38.  
  39. function checkWood()
  40. success,data=turtle.inspect()
  41.   if wood[data.name] then
  42.     return true
  43.   else
  44.     return false
  45.   end
  46. end
  47.  
  48. function checkWoodDown()
  49. success,data=turtle.inspectDown()
  50.   if wood[data.name] then
  51.     return true
  52.   else
  53.     return false
  54.   end
  55. end
  56.  
  57. function checkWoodUp()
  58. success,data=turtle.inspectUp()
  59.   if wood[data.name] then
  60.     return true
  61.   else
  62.     return false
  63.   end
  64. end
  65.  
  66. function checkIgnoreDown()
  67. success,data=turtle.inspectDown()
  68.   if ignore[data.name] then
  69.     return true
  70.   else
  71.     return false
  72.   end
  73. end
  74.  
  75. function checkIgnore()
  76. success,data=turtle.inspect()
  77.   if ignore[data.name] then
  78.     return true  
  79.   else
  80.     return false  
  81.   end
  82. end
  83.  
  84. --Branch Cutting--
  85.  
  86. function jc()
  87.   if checkWoodUp() == true then
  88.     turtle.digUp()
  89.   end
  90.   if checkWoodDown() == true then
  91.     turtle.digDown()
  92.   end
  93. end
  94.  
  95. function cutBranch1()
  96.   jc()
  97.   dc()
  98.   tf()
  99.   jc()
  100.   tr()
  101.   dc()
  102.   tf()
  103.   jc()
  104.   tl()
  105.   for i = 1, 2 do
  106.     dc()
  107.     tf()
  108.     jc()
  109.   end
  110.   jc()
  111.   tl()
  112.   dc()
  113.   tf()
  114.   jc()
  115.   tl()
  116.   for i = 1, 2 do
  117.     dc()
  118.     tf()
  119.     jc()
  120.   end
  121.   jc()
  122.   tr()
  123.   dc()
  124.   tf()
  125.   jc()
  126.   tr()
  127.   for i = 1,2 do
  128.     dc()
  129.     tf()
  130.     jc()
  131.   end
  132.   tr()
  133.   tf()
  134.   tr()
  135.   for i = 1, 3 do
  136.     tf()
  137.   end
  138.   tl()
  139. end
  140.  
  141.  
  142. function dc()
  143.   if checkWoodDown() == true then
  144.     turtle.digDown()
  145.   end  
  146.   if turtle.detect() then
  147.     turtle.dig()
  148.   end
  149.   if checkWoodUp() == true then
  150.     turtle.digUp()
  151.   end
  152. end
  153.  
  154. function checkJungleBranch()
  155. --SIDE1__
  156.   if checkWood() == true then
  157.     turtle.dig()
  158.     tf()
  159.     jc()
  160.     tu()
  161.     cutBranch1()
  162.     td()
  163.   else
  164.     tf()
  165.     tr()
  166.   end
  167.   if checkWoodUp() == true then
  168.     tl()
  169.     for i = 1, 2 do
  170.       turtle.digUp()
  171.       tu()
  172.     end
  173.     cutBranch1()
  174.     td()
  175.     td()
  176.   end
  177.   if checkWoodDown() == true then
  178.     tl()
  179.     cutBranch1()
  180.   end
  181.   if checkWood() == true then
  182.     dc()
  183.     tf()
  184.     tl()
  185.     jc()
  186.     tu()
  187.     cutBranch1()
  188.     td()
  189.   else
  190.     tf()
  191.   end
  192.   if checkWoodUp() == true then
  193.     tl()
  194.     for i = 1, 2 do
  195.       turtle.digUp()
  196.       tu()
  197.     end
  198.     cutBranch1()
  199.     td()
  200.     td()
  201.   end
  202.   if checkWoodDown() == true then
  203.     tl()
  204.     cutBranch1()
  205.   end
  206.   tf()
  207.   tr()
  208. --SIDE 2
  209. --check branch up3
  210. --check branch down3
  211. --check branch forward1
  212.   tf()
  213. --check branch up1
  214. --check branch down1
  215. --check branch forward2
  216.   tf()
  217. --check branch up2
  218. --chech branch down2
  219. --check branch forward3
  220.   tf()
  221.   tr()
  222. --SIDE 3
  223. --check branch up3
  224. --check branch down3
  225. --check branch forward1
  226.   tf()
  227. --check branch up1
  228. --check branch down1
  229. --check branch forward2
  230.   tf()
  231. --check branch up2
  232. --chech branch down2
  233. --check branch forward3
  234.   tf()
  235.   tr()
  236. --SIDE 4
  237. --check branch up3
  238. --check branch down3
  239. --check branch forward1
  240.   tf()
  241. --check branch up1
  242. --check branch down1
  243. --check branch forward2
  244.   tf()
  245. --check branch up2
  246. --chech branch down2
  247. --check branch forward3
  248.  
  249.   tr()
  250.   tf()
  251.   tl()
  252.   for i = 1, 3 do
  253.     td()
  254.     height = height - 1
  255.   end
  256. end    
  257.  
  258.  
  259. function jungleTree()
  260. local success, data = turtle.inspectUp()
  261. if data.metadata == 3 and data.name == "minecraft:log" then
  262.   print("wood detected up")
  263.   turtle.digUp()
  264.   turtle.up()
  265.   height = height + 1
  266.   top = top + 1
  267.   print("Height ", height)
  268.   if turtle.detect() then
  269.     print("Wood detected")
  270.     repeat
  271.       turtle.dig()
  272.       turtle.digUp()
  273.       tu()  
  274.       height = height + 1
  275.       top = top + 1
  276.       print("Height ", height)
  277.     until
  278.       checkWoodUp() == false
  279.     turtle.dig()
  280.     tf()
  281.     tr()
  282.     turtle.dig()
  283.     tf()
  284.     tr()
  285.     turtle.dig()
  286.     for i = 1, height do  
  287.       turtle.digDown()
  288.       td()
  289.       height = height - 1
  290.       turtle.dig()
  291.     end
  292.     if top>=25 and top<=50 then
  293.       for i = 1, top - 1 do
  294.         tu()
  295.         hieght = height + 1
  296.       end
  297.       for i = 1, 5 do
  298.         checkJungleBranch()
  299.         height = height - 3
  300.       end
  301.     elseif  top>=15 and top<=24 then
  302.       for i = 1, top - 1 do
  303.         tu()
  304.         height = height + 1
  305.       end
  306.       for i = 1, 3 do
  307.         checkJungleBranch()
  308.        
  309.         print("Height ", height)
  310.       end
  311.     elseif top>=8 and top<=14 then  
  312.       for i = 1, top - 1 do
  313.         tu()
  314.         height = height + 1
  315.       end
  316.       tf()
  317.       for i = 1, 2 do
  318.         checkJungleBranch()
  319.       end
  320.     end
  321.     for i = 1, height do
  322.       turtle.dig()
  323.       turtle.digDown()
  324.       td()
  325.     end
  326.     turtle.dig()
  327.    
  328.     tr()
  329.     tf()
  330.     tr()
  331.   end
  332.   end  
  333. end    
  334.  
  335.        
  336. function oak()
  337. local success, data = turtle.inspectUp()
  338.   if data.metadata == 0 and data.name == "minecraft:log" then
  339.     print("Oak Found")
  340.     if checkWoodUp() == true then
  341.       repeat
  342.         turtle.digUp()
  343.         print("Cutting Oak")
  344.         tu()
  345.         height = height + 1
  346.       until checkWoodUp() == false
  347.     end  
  348.     if height >5 then
  349.       td()
  350.       td()
  351.       height = height - 2
  352.       for i = 1, 2 do
  353.         dc()
  354.         tf()
  355.         dc()
  356.         tr()
  357.       end
  358.       for i= 1, 2 do
  359.         dc()
  360.         tf()
  361.         dc()
  362.         tf()
  363.         dc()
  364.         tr()
  365.       end
  366.       for i = 1, 2 do
  367.         for i = 1, 3 do
  368.           dc()
  369.           tf()
  370.         end
  371.         tr()
  372.       end
  373.       for i = 1, 2 do
  374.         for i = 1, 4 do
  375.           dc()
  376.           tf()
  377.         end
  378.         tr()
  379.       end      
  380.       for i = 1, 2 do
  381.         for i = 1, 5 do
  382.           dc()
  383.           tf()
  384.         end
  385.         tr()
  386.       end
  387.       for i = 1, 3 do
  388.         for i = 1, 6 do
  389.           dc()
  390.           tf()
  391.         end
  392.         tr()
  393.       end
  394.       for i = 1, 2 do
  395.         for i = 1, 3 do
  396.           tf()
  397.         end
  398.         tr()
  399.       end
  400.       tr()
  401.     end  
  402.   end
  403. end
  404.  
  405.  
  406. --Tree cutting function--
  407.  
  408. function cut()
  409. height = 0
  410.   oak()
  411.   jungleTree()
  412.   if checkWoodUp() == true then
  413.     repeat
  414.       turtle.digUp()
  415.       print("Cutting Regular Tree")
  416.       tu()
  417.       height = height + 1
  418.     until not turtle.detectUp()
  419.     for i = 1, height do
  420.      td()
  421.     end
  422.   end
  423. end
  424.  
  425.  
  426.  
  427. --Move function--
  428.        
  429. function move()
  430.   repeat
  431.     turtle.down()
  432.   until
  433.     turtle.detectDown()
  434.   if checkIgnoreDown() == false then
  435.     repeat
  436.       turtle.digDown()
  437.       td()
  438.     until
  439.       checkIgnoreDown() == true
  440.   end      
  441.   if checkIgnore() == true then
  442.     repeat
  443.       tu()            
  444.     until
  445.       checkIgnore() == false
  446.   end  
  447.   turtle.dig()
  448.   tf()
  449.   cut()  
  450. end
  451.  
  452.    
  453. -- Next row functions--
  454.  
  455. function nextRowLeft()
  456.   tl()
  457.   move()
  458.   tl()
  459. end
  460.        
  461. function nextRowRight()
  462.   tr()
  463.   move()
  464.   tr()
  465. end
  466.  
  467. -----MAIN-----
  468.  
  469. print("Input Length")
  470. givenLength = read()
  471. print("Input Width")
  472. givenWidth = read()
  473.  
  474.  
  475. for i = 1, givenWidth do        
  476.   for i = 1, givenLength do
  477.     move()
  478.   end
  479.   if direction == 1 then
  480.     nextRowLeft()
  481.     direction = 2
  482.   else
  483.     nextRowRight()
  484.     direction = 1
  485.   end  
  486. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement