Advertisement
sinkir

lua turtle Bee Breeding

Apr 16th, 2013
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1. -- pastebin get MPZeT0AT startup
  2. --   _____
  3. --  |  ___|   _ _ __   ___
  4. --  | |_ | | | | '_ \ / __|
  5. --  |  _|| |_| | | | | (__
  6. --  |_|   \__,_|_| |_|\___|
  7. --
  8.  
  9.  
  10.  
  11. select = function(id)
  12.     return turtle.select(id)
  13. end
  14.  
  15. count = function(id)
  16.     return turtle.getItemCount(id)
  17. end
  18.  
  19. move = function(id, nb)
  20.     return turtle.transferTo(id, nb)
  21. end
  22.  
  23. suck = function()
  24.     return turtle.suck()
  25. end
  26.  
  27. dropUp = function()
  28.     return turtle.dropUp()
  29. end
  30.  
  31. dropDown = function()
  32.     return turtle.dropDown()
  33. end
  34.  
  35. compare = function()
  36.     local j = 0
  37.     for j = 9, 16 do
  38.         if(turtle.compareTo(j)==true)then
  39.             return true
  40.         end
  41.     end
  42.     return false
  43. end
  44.  
  45. compareAll = function()
  46. -- return True si on trouve un idem qui n'est pas dans la liste (slot 9,16)
  47.  
  48.     local j = 0
  49.     local k = 0
  50.     local flag = false
  51.  
  52.     for k = 1, 8 do
  53.         if(count(k)>0)then
  54.             select(k)
  55.             flag = false
  56.             for j = 9, 16 do
  57.                 if(count(j)>0)then
  58.                     if(turtle.compareTo(j)==true)then
  59.                          flag = true
  60.                          j=16
  61.                     end
  62.                 end
  63.             end
  64.             if(flag == false)then
  65.                 return true
  66.             end
  67.         end
  68.     end
  69.     return false
  70. end
  71.  
  72. dropDrone = function()
  73.     local k = 0
  74.     local flag = false
  75.     for k = 1, 8 do
  76.         if(count(k)>0)then
  77.             select(k)
  78.             if(turtle.compareTo(16)==true)then
  79.                 dropDown(count(16))
  80.                 flag = true
  81.             end
  82.         end
  83.     end
  84.     return flag
  85. end
  86.  
  87. dropReste = function()
  88.     local i = 0
  89.     for i = 1, 8 do
  90.         if(count(i)>0)then
  91.             select(i)
  92.             if(compare()==true)then
  93.                 dropDown(count(i))
  94.             else
  95.                 dropUp(count(i))
  96.             end
  97.         end
  98.     end
  99. end
  100. function stuff()
  101.     if(compareAll()==true)then
  102.         dropDrone()
  103.         dropReste()
  104.     end
  105. end
  106.  
  107. --  __  __       _        ____
  108. -- |  \/  | __ _(_)_ __  / /\ \
  109. -- | |\/| |/ _` | | '_ \| |  | |
  110. -- | |  | | (_| | | | | | |  | |
  111. -- |_|  |_|\__,_|_|_| |_| |  | |
  112. --                       \_\/_/
  113.  
  114.  
  115.  
  116. stop=false
  117. local l = 0
  118.  
  119. select(1)
  120. while(stop==false)do
  121.     for l = 1, 8 do
  122.         if(count(l)>0)then
  123.             stuff()
  124.         end
  125.     end
  126.     select(1)
  127.     while suck() do
  128.         sleep(1)
  129.     end
  130.     sleep(3)
  131. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement