Advertisement
Guest User

coupe.lua

a guest
Feb 18th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. saplings = 1 -- the slot where the saplings are
  2. charbon = 2
  3. bois=3
  4. coffre=4
  5.  
  6. function reEnergy()
  7.     turtle.suckDown()
  8.     turtle.select(charbon)
  9.     if turtle.getFuelLevel() < 800 then
  10.         turtle.refuel()
  11.     end
  12.     if turtle.getFuelLevel() < 100 then
  13.         print('No much fuel !')
  14.         os.shutdown()
  15.     end
  16.     turtle.select(saplings)
  17. end
  18.  
  19. function pose()
  20.     turtle.select(bois)
  21.     turtle.drop(turtle.getItemCount(bois)-1)
  22.     turtle.select(saplings)
  23. end
  24.    
  25.  
  26. turtle.select(saplings) -- select the saplings
  27. while turtle.getItemCount(saplings) > 0 do -- while more saplings in inventory
  28.     turtle.select(coffre)
  29.     turtle.turnLeft()
  30.     if turtle.compare() then
  31.         reEnergy()
  32.         pose()
  33.     end
  34.     turtle.turnRight()
  35.     turtle.select(saplings)
  36.     for i = 1, 5 do -- plant 5 saplings in a row
  37.         turtle.turnRight()
  38.         if not turtle.compare() then -- if not a sapling, then a tree grew
  39.             turtle.dig()
  40.             turtle.forward()
  41.             turtle.select(bois)
  42.             while turtle.compareUp() do -- dig tree out
  43.                 turtle.digUp()
  44.                 turtle.up()
  45.             end
  46.             turtle.select(saplings)
  47.             while not turtle.detectDown() do -- back down to ground
  48.                 turtle.down()
  49.             end
  50.             turtle.back()
  51.             turtle.place() -- put down new sapling
  52.         end
  53.         turtle.turnLeft()
  54.         turtle.forward()
  55.     end
  56.     -- turn around and line up for next pass
  57.     turtle.turnRight()
  58.     turtle.forward()
  59.     turtle.forward()
  60.     turtle.turnRight()
  61.     turtle.forward()
  62.     os.sleep(180) -- sleep for 60 seconds to allow trees to grow
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement