Advertisement
Vodka51200

fermecarotepatatechene

Jul 1st, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.36 KB | None | 0 0
  1. --------------------------------------
  2. -----   Created by Batponney     -----
  3. ----- On Server ComputerCraftFR  -----
  4. --------------------------------------
  5.  
  6. function select_next_item(slot, item)
  7.    
  8.     while slot <= 16 do
  9.         data = turtle.getItemDetail(slot)
  10.         if data and data.name == item then
  11.             turtle.select(slot)
  12.             return true
  13.         end
  14.         slot = slot + 1
  15.     end
  16.     return false
  17. end
  18.  
  19. function repack_item(item)
  20.     slot = 1
  21.    
  22.     while slot < 16 do
  23.         data = turtle.getItemDetail(slot)
  24.         if not data or (data.name == item and data.count < 64) then
  25.             if select_next_item(slot + 1, item) then
  26.                 turtle.transferTo(slot)
  27.                 data = turtle.getItemDetail(slot)
  28.                 else
  29.                 return true
  30.             end
  31.         end
  32.         if data and ((data.name == item and data.count == 64) or data.name ~= item) then
  33.             slot = slot + 1
  34.         end
  35.     end
  36.     return true
  37. end
  38.  
  39. function scan(slot)
  40.   data = turtle.getItemDetail(slot)
  41.   if data then
  42.     return data.name
  43.   else return false
  44.   end
  45. end
  46.  
  47. function find(Name)
  48.   slot = 1
  49.   while slot <= 16 do
  50.     data = turtle.getItemDetail(slot)
  51.     if data and data.name == Name then
  52.       turtle.select(slot)
  53.       return true
  54.     end
  55.     slot = slot+1
  56.   end
  57.   return false
  58. end
  59.  
  60. function plante(item)
  61.   if find(item) == true then
  62.     turtle.placeDown()  
  63.   else
  64.     while find(item) == false do
  65.       print("Not enought "..item.." : retrying in 5 second")
  66.       sleep(5)
  67.     end
  68.     turtle.placeDown()
  69.   end
  70. end
  71.  
  72.  
  73.  
  74. function inspect(direction)
  75.  
  76.   if direction == "up" then
  77.     success, data = turtle.inspectUp()
  78.   elseif direction == "front" then
  79.     success, data = turtle.inspect()
  80.   elseif direction == "down" then
  81.     success, data = turtle.inspectDown()
  82.   end
  83.   if success then
  84.     return data.name
  85.   else
  86.     return "none"
  87.   end
  88. end
  89.  
  90.  
  91. function inspectMetadata(direction)
  92.  
  93.   if direction == "up" then
  94.     success, data = turtle.inspectUp()
  95.   elseif direction == "front" then
  96.     success, data = turtle.inspect()
  97.   elseif direction == "down" then
  98.     success, data = turtle.inspectDown()
  99.   end
  100.   if success then
  101.     return data.metadata
  102.   else
  103.     return "none"
  104.   end
  105. end
  106.  
  107. function check()
  108.   if inspect("down") == "minecraft:carrots" and inspectMetadata("down") == 7 then
  109.     turtle.digDown()
  110.     find("minecraft:carrot")
  111.     turtle.placeDown()
  112.   elseif inspect("down") == "minecraft:potatoes" and inspectMetadata("down") == 7 then
  113.     turtle.digDown()
  114.     find("minecraft:potato")
  115.     turtle.placeDown()
  116.   end
  117. end
  118.  
  119. function coupe()
  120.   turtle.dig()
  121.   turtle.forward()
  122.   turtle.digDown()
  123.   while inspect("up") == "minecraft:log" or inspect("up") == "minecraft:leaves" do
  124.     turtle.digUp()
  125.     tour = 1
  126.     while tour <= 4 do
  127.       turtle.dig()
  128.       turtle.turnRight()
  129.       tour = tour + 1
  130.     end
  131.     turtle.up()
  132.   end
  133.   while turtle.down() == true do
  134.     turtle.down()
  135.   end
  136.     turtle.up()
  137.     plante("minecraft:sapling")
  138. end
  139.  
  140.  
  141.  
  142. function vide()
  143. slot = 1
  144.   while slot <= 16 do
  145.     turtle.select(slot)
  146.     if scan(slot) == "minecraft:sapling" then
  147.         turtle.dropDown(turtle.getItemCount(slot)-12)
  148.         slot = slot + 1
  149.       else
  150.         turtle.dropDown()
  151.         slot = slot + 1
  152.  
  153.       end
  154.   end
  155. end
  156.  
  157.  
  158. print("Hello")
  159. print("Can I go ?")
  160. answer = read()
  161. if answer == "y" then
  162.     if turtle.getFuelLevel() < 400 then
  163.       turtle.back()
  164.       sleep(10)
  165.       turtle.forward()      
  166.     end
  167.     y = 1
  168.     state = 2
  169.     turtle.up()
  170.     turtle.forward()
  171.     planted = "potato"
  172.     while y < 26 do
  173.       x = 1
  174.       while x < 9 do
  175.        if inspect("front") == "minecraft:log" then
  176.         coupe()
  177.        elseif inspect("front") == "minecraft:leaves" then
  178.         turtle.dig()
  179.        elseif inspectMetadata("down") == 7 then
  180.         turtle.digDown()
  181.         if planted == "potato" and find("minecraft:carrot") then
  182.           plante("minecraft:carrot")
  183.           planted = "carrot"
  184.         elseif planted == "carrot" and find("minecraft:potato") then
  185.           plante("minecraft:potato")
  186.           planted = "potato"
  187.         else
  188.           if find("minecraft:potato") then
  189.             plante("minecraft:potato")
  190.           elseif find("minecraft:carrot") then
  191.             plante("minecraft:carrot")
  192.           end
  193.         end
  194.        end
  195.         turtle.suckDown()
  196.         turtle.forward()
  197.         x = x+1
  198.       end
  199.       if state == 2 then
  200.         check()
  201.         turtle.turnLeft()
  202.         turtle.suckDown()
  203.         turtle.suckDown()
  204.         turtle.forward()
  205.         check()
  206.         turtle.turnLeft()
  207.         state = 1
  208.       elseif state == 1 then
  209.         check()
  210.         turtle.turnRight()
  211.         turtle.suckDown()
  212.         turtle.forward()
  213.         turtle.suckDown()
  214.         check()
  215.         turtle.turnRight()
  216.         state = 2
  217.       end
  218.       y = y + 1
  219.     end
  220.     turtle.turnLeft()
  221.     while turtle.forward() == true do
  222.       turtle.suckDown()
  223.       turtle.forward()
  224.     end
  225.     turtle.turnRight()
  226.     while turtle.down() == false do
  227.       turtle.suckDown()
  228.       turtle.forward()
  229.     end
  230.     turtle.turnRight()
  231.     turtle.turnRight()
  232.     repack_item("minecraft:sapling")
  233.     vide()
  234.     os.reboot()
  235.   elseif answer == "Maj" then
  236.     shell.run("Maj")
  237.   else os.reboot()  
  238.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement