Advertisement
Guest User

cc

a guest
Jan 18th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.17 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. function cutBranchC()
  142.   for i = 1, 2 do
  143.     dc()
  144.     tf()
  145.     jc()
  146.   end
  147.   tl()
  148.   dc()
  149.   tf()
  150.   jc()
  151.   tl()
  152.   for i = 1, 2 do
  153.     dc()
  154.     tf()
  155.     jc()
  156.   end
  157.   tr()
  158.   dc()
  159.   tf()
  160.   jc()
  161.   tr()
  162.   for i = 1, 2 do
  163.     dc()
  164.     tf()
  165.     jc()
  166.   end
  167.   tr()
  168.   tf()
  169.   tf()
  170.   tr()
  171.   tf()
  172.   tf()
  173.   tl()
  174. end
  175.  
  176. function dc()
  177.   if checkWoodDown() == true then
  178.     turtle.digDown()
  179.   end  
  180.   if turtle.detect() then
  181.     turtle.dig()
  182.   end
  183.   if checkWoodUp() == true then
  184.     turtle.digUp()
  185.   end
  186. end
  187.  
  188. function checkJungleBranch()
  189. --SIDE1__BLOCK1
  190.   if checkWood() == true then
  191.     turtle.dig()
  192.     tf()
  193.     jc()
  194.     tu()
  195.     cutBranch1()
  196.     td()
  197.   else
  198.     tf()
  199.     tr()
  200.   end----------------------------------------------
  201.   if checkWoodUp() == true then
  202.     tl()
  203.     for i = 1, 2 do
  204.       turtle.digUp()
  205.       tu()
  206.     end
  207.     cutBranch1()
  208.     td()
  209.     td()
  210.   end
  211.   if checkWoodDown() == true then
  212.     tl()
  213.     cutBranch1()
  214.   end
  215. --BLOCK2
  216.   if checkWood() == true then
  217.     turtle.dig()
  218.     tu()
  219.     tl()
  220.     cutBranch1()
  221.     td()
  222.   else
  223.     tf()
  224.   end
  225.   if checkWoodUp() == true then
  226.     tl()
  227.     for i = 1, 2 do
  228.       turtle.digUp()
  229.       tu()
  230.     end
  231.     cutBranch1()
  232.     td()
  233.     td()
  234.   end
  235.   if checkWoodDown() == true then
  236.     tl()
  237.     cutBranch1()
  238.   end
  239. --CORNER
  240.   if checkWood() == true then
  241.     dc()
  242.     tf()
  243.     jc()
  244.     tu()
  245.     cutBranchC()
  246.     td()
  247.   else
  248.     tf()
  249.     tr()
  250.   end
  251.  
  252. --SIDE 2
  253. --check branch up3
  254. --check branch down3
  255. --check branch forward1
  256.   tf()
  257. --check branch up1
  258. --check branch down1
  259. --check branch forward2
  260.   tf()
  261. --check branch up2
  262. --chech branch down2
  263. --check branch forward3
  264.   tf()
  265.   tr()
  266. --SIDE 3
  267. --check branch up3
  268. --check branch down3
  269. --check branch forward1
  270.   tf()
  271. --check branch up1
  272. --check branch down1
  273. --check branch forward2
  274.   tf()
  275. --check branch up2
  276. --chech branch down2
  277. --check branch forward3
  278.   tf()
  279.   tr()
  280. --SIDE 4
  281. --check branch up3
  282. --check branch down3
  283. --check branch forward1
  284.   tf()
  285. --check branch up1
  286. --check branch down1
  287. --check branch forward2
  288.   tf()
  289. --check branch up2
  290. --chech branch down2
  291. --check branch forward3
  292.  
  293.   tr()
  294.   tf()
  295.   tl()
  296.   for i = 1, 3 do
  297.     td()
  298.     height = height - 1
  299.   end
  300. end    
  301.  
  302.  
  303. function jungleTree()
  304. local success, data = turtle.inspectUp()
  305. if data.metadata == 3 and data.name == "minecraft:log" then
  306.   print("wood detected up")
  307.   turtle.digUp()
  308.   turtle.up()
  309.   height = height + 1
  310.   top = top + 1
  311.   print("Height ", height)
  312.   if turtle.detect() then
  313.     print("Wood detected")
  314.     repeat
  315.       turtle.dig()
  316.       turtle.digUp()
  317.       tu()  
  318.       height = height + 1
  319.       top = top + 1
  320.       print("Height ", height)
  321.     until
  322.       checkWoodUp() == false
  323.     turtle.dig()
  324.     tf()
  325.     tr()
  326.     turtle.dig()
  327.     tf()
  328.     tr()
  329.     turtle.dig()
  330.     for i = 1, height do  
  331.       turtle.digDown()
  332.       td()
  333.       height = height - 1
  334.       turtle.dig()
  335.     end
  336.     if top>=25 and top<=50 then
  337.       for i = 1, top - 1 do
  338.         tu()
  339.         hieght = height + 1
  340.       end
  341.       for i = 1, 5 do
  342.         checkJungleBranch()
  343.         height = height - 3
  344.       end
  345.     elseif  top>=15 and top<=24 then
  346.       for i = 1, top - 1 do
  347.         tu()
  348.         height = height + 1
  349.       end
  350.       for i = 1, 3 do
  351.         checkJungleBranch()
  352.        
  353.         print("Height ", height)
  354.       end
  355.     elseif top>=8 and top<=14 then  
  356.       for i = 1, top - 1 do
  357.         tu()
  358.         height = height + 1
  359.       end
  360.       tf()
  361.       for i = 1, 2 do
  362.         checkJungleBranch()
  363.       end
  364.     end
  365.     for i = 1, height do
  366.       turtle.dig()
  367.       turtle.digDown()
  368.       td()
  369.     end
  370.     turtle.dig()
  371.    
  372.     tr()
  373.     tf()
  374.     tr()
  375.   end
  376.   end  
  377. end    
  378.  
  379.        
  380. function oak()
  381. local success, data = turtle.inspectUp()
  382.   if data.metadata == 0 and data.name == "minecraft:log" then
  383.     print("Oak Found")
  384.     if checkWoodUp() == true then
  385.       repeat
  386.         turtle.digUp()
  387.         print("Cutting Oak")
  388.         tu()
  389.         height = height + 1
  390.       until checkWoodUp() == false
  391.     end  
  392.     if height >5 then
  393.       td()
  394.       td()
  395.       height = height - 2
  396.       for i = 1, 2 do
  397.         dc()
  398.         tf()
  399.         dc()
  400.         tr()
  401.       end
  402.       for i= 1, 2 do
  403.         dc()
  404.         tf()
  405.         dc()
  406.         tf()
  407.         dc()
  408.         tr()
  409.       end
  410.       for i = 1, 2 do
  411.         for i = 1, 3 do
  412.           dc()
  413.           tf()
  414.         end
  415.         tr()
  416.       end
  417.       for i = 1, 2 do
  418.         for i = 1, 4 do
  419.           dc()
  420.           tf()
  421.         end
  422.         tr()
  423.       end      
  424.       for i = 1, 2 do
  425.         for i = 1, 5 do
  426.           dc()
  427.           tf()
  428.         end
  429.         tr()
  430.       end
  431.       for i = 1, 3 do
  432.         for i = 1, 6 do
  433.           dc()
  434.           tf()
  435.         end
  436.         tr()
  437.       end
  438.       for i = 1, 2 do
  439.         for i = 1, 3 do
  440.           tf()
  441.         end
  442.         tr()
  443.       end
  444.       tr()
  445.     end  
  446.   end
  447. end
  448.  
  449.  
  450. --Tree cutting function--
  451.  
  452. function cut()
  453. height = 0
  454.   oak()
  455.   jungleTree()
  456.   if checkWoodUp() == true then
  457.     repeat
  458.       turtle.digUp()
  459.       print("Cutting Regular Tree")
  460.       tu()
  461.       height = height + 1
  462.     until not turtle.detectUp()
  463.     for i = 1, height do
  464.      td()
  465.     end
  466.   end
  467. end
  468.  
  469.  
  470.  
  471. --Move function--
  472.        
  473. function move()
  474.   repeat
  475.     turtle.down()
  476.   until
  477.     turtle.detectDown()
  478.   if checkIgnoreDown() == false then
  479.     repeat
  480.       turtle.digDown()
  481.       td()
  482.     until
  483.       checkIgnoreDown() == true
  484.   end      
  485.   if checkIgnore() == true then
  486.     repeat
  487.       tu()            
  488.     until
  489.       checkIgnore() == false
  490.   end  
  491.   turtle.dig()
  492.   tf()
  493.   cut()  
  494. end
  495.  
  496.    
  497. -- Next row functions--
  498.  
  499. function nextRowLeft()
  500.   tl()
  501.   move()
  502.   tl()
  503. end
  504.        
  505. function nextRowRight()
  506.   tr()
  507.   move()
  508.   tr()
  509. end
  510.  
  511. -----MAIN-----
  512.  
  513. print("Input Length")
  514. givenLength = read()
  515. print("Input Width")
  516. givenWidth = read()
  517.  
  518.  
  519. for i = 1, givenWidth do        
  520.   for i = 1, givenLength do
  521.     move()
  522.   end
  523.   if direction == 1 then
  524.     nextRowLeft()
  525.     direction = 2
  526.   else
  527.     nextRowRight()
  528.     direction = 1
  529.   end  
  530. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement