Advertisement
SythsGod

Tree Chopping Code (Fir)

Jun 6th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.15 KB | None | 0 0
  1. -------------------------------------------------------------------------------------------------------------------
  2. -- tomorrow, there'll be a video released with the whole setup used with this code! be sure to keep an eye
  3. -- out on this channel    --> www.youtube.com/user/sythsgod
  4. -------------------------------------------------------------------------------------------------------------------
  5. -- functions
  6. function plant()
  7.   a = turtle.getItemCount(2)
  8.   if a < 4 then
  9.     sapling()
  10.     plantadd()
  11.   else
  12.     plantadd()
  13.   end
  14. end
  15.  
  16.  
  17. function plantadd()
  18.   turtle.select(2)
  19.   turtle.forward()
  20.   sleep(0.5)
  21.   turtle.place()
  22.   turtle.turnLeft()
  23.   turtle.forward()
  24.   turtle.turnRight()
  25.   sleep(0.5)
  26.   turtle.place()
  27.   turtle.back()
  28.   sleep(0.5)
  29.   turtle.place()
  30.   turtle.turnRight()
  31.   turtle.forward()
  32.   turtle.turnLeft()
  33.   sleep(0.5)
  34.   turtle.place()
  35.   sleep(0.2)
  36.   term.clear()
  37.   term.setCursorPos(1,1)
  38.   sleep(0.2)
  39.   textutils.slowPrint("Saplings planted!")
  40.   term.clear()
  41.   term.setCursorPos(1,1)
  42.   textutils.slowPrint("Done 1!")
  43.   sleep(0.6)
  44. end
  45.  
  46.  
  47.  
  48. function sapling()
  49.   do
  50.     turtle.turnRight()
  51.     turtle.back()
  52.     turtle.turnLeft()
  53.     turtle.back()
  54.     turtle.back()
  55.     turtle.up()
  56.     turtle.back()
  57.     turtle.select(2)
  58.     turtle.suckUp()
  59.     turtle.forward()
  60.     turtle.down()
  61.     turtle.forward()
  62.     turtle.forward()
  63.     turtle.turnRight()
  64.     turtle.forward()
  65.     turtle.turnLeft()
  66.   end
  67. end
  68.      
  69.  
  70. function grow()
  71.   b = turtle.getItemCount(1)
  72.   if b == 0 then
  73.     bonemeal()
  74.     growadd()
  75.   else
  76.     growadd()
  77.   end
  78. end
  79.  
  80. function growadd()
  81.   turtle.select(1)
  82.   turtle.place()
  83.   sleep(0.5)
  84.   term.clear()
  85.   term.setCursorPos(1,1)
  86.   textutils.slowPrint("Tree successfully grown!")
  87.   sleep(1)
  88.   term.clear()
  89.   term.setCursorPos(1,1)
  90.   print("Done 1!")
  91.   sleep(0.2)
  92.   textutils.slowPrint("Done 2!")
  93.   textutils.slowPrint("Chopping tree..")
  94.   sleep(0.2)
  95.   turtle.dig()
  96.   turtle.forward()
  97.   turtle.dig()
  98. end
  99.  
  100. function bonemeal()
  101.   do
  102.     turtle.back()
  103.     turtle.back()
  104.     turtle.up()
  105.     turtle.back()
  106.     turtle.select(1)
  107.     turtle.suckUp()
  108.     turtle.forward()
  109.     turtle.down()
  110.     turtle.forward()
  111.     turtle.forward()
  112.     sleep(0.2)
  113.     turtle.place()
  114.   end
  115. end
  116.  
  117. function fellup()
  118.   for c = 1,45 do
  119.     turtle.digUp()
  120.     turtle.up()
  121.     turtle.dig()
  122.   end
  123. end
  124.  
  125. function switch()
  126.   do
  127.     turtle.turnLeft()
  128.     turtle.dig()
  129.     turtle.forward()
  130.     turtle.turnRight()
  131.     turtle.dig()
  132.   end
  133. end
  134.  
  135. function felldown()
  136.   for d = 1,45 do
  137.     turtle.digDown()
  138.     turtle.down()
  139.     turtle.dig()
  140.   end
  141. end
  142.  
  143. function store()
  144.   do
  145.     term.clear()
  146.     term.setCursorPos(1,1)
  147.     textutils.slowPrint("Tree successfully chopped!")
  148.     sleep(1)
  149.     print("Done 1!")
  150.     print("Done 2!")
  151.     sleep(0.2)
  152.     textutils.slowPrint("Done 3!")
  153.     term.clear()
  154.     term.setCursorPos(1,1)
  155.     textutils.slowPrint("Starting storing event..")
  156.     turtle.turnLeft()
  157.     turtle.forward()
  158.     turtle.turnLeft()
  159.     turtle.forward()
  160.     turtle.forward()
  161.     turtle.forward()
  162.     turtle.forward()
  163.     turtle.up()
  164.     turtle.turnLeft()
  165.     turtle.forward()
  166.     turtle.forward()
  167.     turtle.turnLeft()
  168.     turtle.select(3)
  169.     turtle.dropDown()
  170.     turtle.select(4)
  171.     turtle.dropDown()
  172.     turtle.select(5)
  173.     turtle.dropDown()
  174.     turtle.select(6)
  175.     turtle.dropDown()
  176.     turtle.select(7)
  177.     turtle.dropDown()
  178.     turtle.select(8)
  179.     turtle.dropDown()
  180.     turtle.select(9)
  181.     turtle.dropDown()
  182.     turtle.forward()
  183.     turtle.down()
  184.     turtle.forward()
  185.     turtle.forward()
  186.     term.clear()
  187.     term.setCursorPos(1,1)
  188.     textutils.slowPrint("Successfully stored all items!")
  189.     sleep(1)
  190.     term.clear()
  191.     term.setCursorPos(1,1)
  192.     print("Done 1!")
  193.     print("Done 2!")
  194.     print("Done 3!")
  195.     sleep(0.2)
  196.     textutils.slowPrint("Done 4!")
  197.     textutils.slowPrint("Waiting for restart of program!")
  198.   end
  199. end
  200.  
  201.  
  202.  
  203.  
  204.  
  205. -- main program
  206.  
  207. print("How many times should the program be repeated?")
  208. c = tonumber(read())
  209.  
  210. for t = 1,c do
  211.   plant()
  212.   sleep(1)
  213.   grow()
  214.   fellup()
  215.   switch()
  216.   felldown()
  217.   store()
  218. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement