Advertisement
Wafflesword72

Farm

Aug 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.05 KB | None | 0 0
  1. -- globals
  2. local slot = 1
  3. local oak = false
  4.  
  5. function firstrow()
  6.  turtle.forward()
  7.  turtle.forward()
  8.  turtle.forward()
  9.  turtle.turnLeft()
  10. end
  11.  
  12. function nextrow()
  13.  turtle.turnRight()
  14.  turtle.forward()
  15.  turtle.forward()
  16.  turtle.forward()
  17.  turtle.turnLeft()
  18. end
  19.  
  20. function tree()
  21.  
  22.  --start from previous tree
  23.  turtle.forward()
  24.  turtle.forward()
  25.  -- moved to tree
  26.  turtle.dig()
  27.  turtle.forward()
  28.  --Start digging tree
  29.  for i=1,6 do
  30.   turtle.digUp()
  31.   turtle.up()
  32.  end
  33.  --Going down to ground
  34.  for i=1,6 do
  35.   turtle.down()
  36.  end
  37. end
  38.  
  39. function cycleSlots()
  40.       slot = slot + 1 -- selects next slot
  41.       if slot <=  16 then -- makes sure its not more then the slots in the turtle
  42.         turtle.select(slot)
  43.         oak = false
  44.       end
  45. end
  46.  
  47. function findSapling()
  48.  local item = turtle.getItemDetail()
  49.   if item then
  50.    
  51.     local count = item.count
  52.     local name = item.name
  53.     local damage = item.damage
  54.    
  55.      if name == "minecraft:sapling" and damage == 0 then
  56.       turtle.place() -- placing sapling
  57.       print("yes!")
  58.       oak = true
  59.       else
  60.      
  61.      print(slot,"is a nope ", count, " ", name, " ", damage) -- debugging
  62.      
  63.      cycleSlots()
  64.      
  65.      if slot == 16 and oak == false then
  66.         saplings() -- goes to find more saplings from storage if found nothing in the 16 slots
  67.      end
  68.      
  69.     end
  70.   else     
  71.    turtle.select(slot)
  72.    slot = slot+1
  73.    print("changing slot to:",slot-1)
  74.   end
  75. end
  76.  
  77. function plant()
  78.   turtle.back()
  79.  
  80.   while oak == false do
  81.    
  82.  end
  83.  turtle.back()
  84.  turtle.back()
  85.  
  86. end
  87.  
  88. function saplings()
  89. -- add path finding to chest for more saplings or home here
  90. print("No saplings in turtle :( ")
  91. end
  92.  
  93. function row()
  94.  local trees = 10
  95.   for i=1,trees do
  96.    tree()
  97.   end
  98.   for i=1,trees-1 do
  99.    plant()
  100.   end
  101. end
  102. -- start of program
  103.  
  104. print("fuel level: ", turtle.getFuelLevel())
  105.  
  106. --first row
  107. --firstrow()
  108. --turtle.forward()
  109.  
  110. -- row 1
  111. --row()
  112. --nextrow()
  113.  
  114. -- row 2
  115. --row()
  116. --nextrow()
  117.  
  118. -- row 3
  119. --row()
  120.  
  121. -- to home
  122.  
  123. -- reset slot to 1
  124. turtle.select(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement