Advertisement
Efud933

TreeFarm1.2

Jan 4th, 2022
954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  1. --BasicWoodcutLoop
  2. function cut()
  3.  
  4.     for i = 0,6 do
  5.         turtle.digUp()
  6.         turtle.up()
  7.     end
  8.    
  9.     turtle.dig()
  10.     turtle.forward()
  11.    
  12.     for i = 0,6 do
  13.         turtle.digDown()
  14.         turtle.down()
  15.     end
  16.    
  17.     turtle.forward()
  18.    
  19. end
  20.  
  21. --Basic movement loop
  22. function moveForward()
  23.  
  24.     for i = 0,5 do
  25.         turtle.forward()
  26.     end
  27. end
  28.  
  29. --Turns and plants sapling
  30. function plant()
  31.     turtle.turnLeft()
  32.     turtle.turnLeft()
  33.     turtle.place()
  34.     turtle.turnLeft()
  35.     turtle.turnLeft()
  36. end
  37.  
  38. --Cuts entire column of trees
  39. function cutColumn()
  40.     for i = 1,treesInColumn do  
  41.         cut()
  42.         plant()
  43.         if counter < timesToMove then
  44.             moveForward()
  45.             counter = counter + 1
  46.         end
  47.     end
  48.     counter = 0
  49. end
  50.  
  51. --Updates Faceinit value to current facing (True if facing initial direction, false if opposite)
  52. function updateFacing()
  53.     if faceInit == true then
  54.         faceInit = false
  55.         else
  56.         faceInit = true
  57.     end
  58. end
  59.  
  60. --Moves between rows to cut the next one
  61. function moveRows()
  62.     if faceInit == true then
  63.         turtle.turnRight()
  64.     else
  65.         turtle.turnLeft()
  66.     end
  67.     moveForward()
  68.     if faceInit == true then
  69.         turtle.turnRight()
  70.     else
  71.         turtle.turnLeft()
  72.     end
  73.     updateFacing()
  74.  
  75.  
  76. end
  77.  
  78.  
  79.    
  80.          
  81.  
  82.  
  83. --RunTime Loop
  84. run = true
  85. faceInit = true
  86. treesInColumn = 3 -- UPDATE ME TO FIT SIZE OF TREE FARM
  87. numOfColumns = 3 -- UPDATE ME TO FIZE SIZE OF TREE FARM
  88. timesToMove = treesInColumn - 1
  89. counter = 0
  90.  
  91. while run == true do
  92.  
  93.     for i = 1,numOfColumns do
  94.         cutColumn()
  95.         moveRows()
  96.  
  97.    
  98.     end
  99.    
  100.    -- run = false
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement