MrReps

Turtle automation of botania flower (daisy or orchid)

Apr 21st, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.35 KB | None | 0 0
  1. -- This programme is developed by MrReps. You can use it as you want                                            --
  2. -- Thanks to MinoCraft ( youTube chanel https://www.youtube.com/channel/UCt1I1rEBRLYRE0sUhSTI_Tg)               --
  3. --  for his help and tutorial                                                                                   --
  4. -- If they are any problem contact me on pastebin, and i will fixe it                                           --
  5. --                                          Working                                                             --
  6. -- the Turtle moves forward and puts block under it or it will be replace by a new block, if it has changed by  --
  7. -- a botania flower (stone into livingstone, stone into ores....). When it meets a block, it TURN RIGHT,        --
  8. -- if it's a chest, the turtle take coal, block (stone, wood, netherrack...) and drop into the chest what it    --
  9. -- has mine. If they are a redstone signal on the turtle, the turtle is stop until it be off                    --
  10. -- The slot 1 is for the block, which will be placed by the turtle (stone, wood...)                             --
  11. -- The slot 2 is for the chest (it's can be all chest vanilla or not)                                           --
  12. -- The slot 16 is for the coal, you can also use things can burn but you need ajust "coalMin" if you use thing, --
  13. -- which have a poor burn value or if the turtle have a long travel between each chest.                         --
  14. -- Don't forget to active Waitingflower when you use pure daisy, to have a breaktime at each chest, like that   --
  15. -- you reduce lag on your serveur. The waiting time can be configure in the "waitTime" (in seconde)             --
  16. -- Use blockmin to have a minimal block into the turtle, if it don't have enought block, it will be stop at a   --
  17. -- chest to wait enought block to restart. Thanks                                                               --
  18.  
  19. local FuelMin = 5           -- level minimal of fuel for the turtle
  20. local coalMin = 4           -- level minimal of coal in the turtle
  21. local blockmin = 0          -- level of minimal block in the turtle, if 0 the fonction is disabled
  22. local Waitingflower = false -- if true wait before moving, if false no waiting
  23. local waitTime = 100        -- waiting time when Waitinflower is active
  24. local rsSide = "left"       -- side where you apply a redstone signal on the turtle
  25.  
  26.  
  27. --Programme
  28. local i = 0 --don't care about this
  29.  
  30.     function redstone() --fonction pour stopper la turtle avec de la redstone
  31.         local reds = false
  32.         reds = rs.getInput(rsSide)
  33.         while reds == true do
  34.             sleep(5)
  35.             reds = rs.getInput(rsSide)
  36.         end
  37.     end
  38.    
  39.     function pause() --fonction d'attente de block
  40.         local stock = 0
  41.         local prendre = 0
  42.         local resultat = false
  43.         if blockmin ~= 0 then
  44.                 turtle.select(1)
  45.                 stock = turtle.getItemCount()
  46.                 if stock < blockmin then
  47.                     resultat = true
  48.                 end
  49.                    
  50.                 while resultat == true do
  51.                 sleep(10)
  52.                 turtle.select(1)
  53.                 prendre = 64 - stock
  54.                 turtle.suck(prendre)
  55.                 for i=1,13 do
  56.                     turtle.select(i+2)
  57.                     turtle.drop()
  58.                     i = i+1
  59.                 end
  60.                 stock = turtle.getItemCount()
  61.                 if stock < blockmin then
  62.                     resultat = true
  63.                 end
  64.             end
  65.         end
  66.     end
  67.    
  68.     function wait() -- fonction pour attente
  69.         if Waitingflower == true then
  70.         sleep(waitTime)
  71.         end
  72.     end
  73.    
  74.     function compareblock()--fonction pour verifier les blocks miner si identique et replacer
  75.         local block = false
  76.        
  77.         turtle.select(1)
  78.         block = turtle.compareDown()
  79.        
  80.         if block == false then
  81.             turtle.digDown()
  82.             turtle.placeDown()
  83.         end
  84.     end
  85.    
  86.     function checkchest() --verifie si c'est un chest, si ou ce vide, se reremplie et se rufuel si besoin
  87.         local block = false
  88.         local prendre = 0
  89.         local stock = 0
  90.        
  91.         turtle.select(2)
  92.         block = turtle.compare()
  93.         if block == true then
  94.             turtle.select(1)
  95.             stock = turtle.getItemCount()
  96.             prendre = 64 - stock
  97.             turtle.suck(prendre)
  98.  
  99.             for i=1,13 do
  100.                 turtle.select(i+2)
  101.                 turtle.drop()
  102.                 i = i+1
  103.             end
  104.  
  105.             Takefuel()
  106.             pause()
  107.             wait()
  108.         end
  109.     end
  110.    
  111.     function checkFuel() -- se refuel si besoin
  112.         local niveauFuel = turtle.getFuelLevel()
  113.         if (niveauFuel ~= "unlimited") then
  114.             if (niveauFuel < FuelMin) then
  115.                 turtle.select(16)
  116.                 turtle.refuel(1)
  117.             end
  118.         end
  119.     end
  120.    
  121.     function Takefuel() --Recupere le fuel dans le chest
  122.         local NBcharbon = 0
  123.         turtle.select(16)
  124.         NBcharbon = turtle.getItemCount()
  125.         if (NBcharbon < coalMin) == true then
  126.             turtle.suck(coalMin)
  127.         end
  128.     end
  129.  
  130.    
  131.    
  132.     while true do -- boucle
  133.         checkFuel()
  134.         checkchest()
  135.         redstone()
  136.         if turtle.detect() == true then
  137.             turtle.turnRight()
  138.         end
  139.         compareblock()
  140.         turtle.forward()
  141.     end
Add Comment
Please, Sign In to add comment