Advertisement
sinkir

lua turtle darkIronFarm

Oct 11th, 2014
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- pastebin get QwPsPGTg startup
  2. -- -------------------------------------------
  3. -- Dark iron farm -Sinkir-
  4. -- Version 1.0 (2014/10/11)
  5. -- slot 1  Wrath Igniter             +-+-+-+-+
  6. -- slot 2  Iron block                |W|I| | |
  7. -- slot 16 Fuel                      | | | | |
  8. --                                   | | | | |
  9. --                                   | | | |F|
  10. --                                   +-+-+-+-+
  11. -- -------------------------------------------
  12. --   _____
  13. --  |  ___|   _ _ __   ___
  14. --  | |_ | | | | '_ \ / __|
  15. --  |  _|| |_| | | | | (__
  16. --  |_|   \__,_|_| |_|\___|
  17. --
  18.  
  19.  
  20.  
  21.  
  22. count = function(id)
  23.     return turtle.getItemCount(id)
  24. end
  25. select = function(id)
  26.     return turtle.select(id)
  27. end
  28. fuel = function()
  29.     return turtle.getFuelLevel()
  30. end
  31.  
  32.  
  33. function testFuel()
  34.     if(fuel() < 1)then
  35.         print('Plus de coco, test de refuel')
  36.         select(16)
  37.         turtle.refuel(1)
  38.     end
  39.     if(count(16) == 0)then
  40.         return false
  41.     end
  42.     return true
  43. end
  44. function checkFuel()
  45.     if(turtle.compareTo(16) == true)then
  46.         if(count(16) < 64) then
  47.             turtle.transferTo(16, turtle.getItemSpace(16))
  48.         end
  49.     end
  50. end
  51.  
  52. function dropAll()
  53.     local flag
  54.     for i=3,15 do
  55.         if(count(i)>0)then
  56.             select(i)
  57.             checkFuel()
  58.             flag = turtle.dropDown()
  59.             if(flag == false)then
  60.                 sleep(1)
  61.                 i = i-1
  62.             end
  63.         end
  64.     end
  65.     return true
  66. end
  67.  
  68. function init()
  69.     if(turtle.detectUp() == true)then
  70.         if(turtle.back() == false)then
  71.             print("can't go back; exit")
  72.             shell.exit()
  73.         else
  74.             return true
  75.         end
  76.     end
  77.     if(turtle.detect() == false)then
  78.         if(count(2) == 0)then
  79.             print("no iron block; reboot")
  80.             sleep(30)
  81.             os.reboot()
  82.         end
  83.     end
  84. end
  85.  
  86. function checkIgniter()
  87.     if(count(1) == 0)then
  88.         select(1)
  89.         if(turtle.suckDown() == false)then
  90.             print("can't get Igniter")
  91.             return false
  92.         end
  93.     end
  94.     return true
  95.  
  96. end
  97.  
  98. function checkIronBlock()
  99.     local i = 0
  100.     if(turtle.detect() == true)then
  101.         select(2)
  102.         if(turtle.compare() == true)then
  103.             i = 0
  104.             while (i < 16)do
  105.                 sleep(0.5)
  106.                 if(turtle.compare() == false)then
  107.                     i = 16
  108.                 else
  109.                     i = i+1
  110.                 end
  111.             end
  112.  
  113.            
  114.             if(turtle.compare() == true)then
  115.                 reIgnite()
  116.             else
  117.                 turtle.dig()
  118.             end
  119.         else
  120.             turtle.dig()
  121.         end
  122.     else
  123.         if(count(2) == 1)then
  124.             select(2)
  125.             turtle.place()
  126.             sleep(10)
  127.             turtle.dig()
  128.             turtle.dropDown()
  129.             sleep(1)
  130.             os.reboot()
  131.         elseif(count(2) > 0)then
  132.             select(2)
  133.             turtle.place()
  134.         else
  135.             sleep(30)
  136.             os.reboot()
  137.         end
  138.     end
  139. end
  140.  
  141. function reIgnite()
  142.     testFuel()
  143.     if(checkIgniter() == false)then
  144.         print("no Igniter; exit")
  145.         shell.exit()
  146.     end
  147.     if(turtle.detect() == true)then
  148.         select(2)
  149.         if(turtle.dig() == true)then
  150.             turtle.forward()
  151.             select(1)
  152.             turtle.place()
  153.             select(2)
  154.             turtle.back()
  155.         end
  156.     end
  157. end
  158.  
  159. --  __  __       _        ____
  160. -- |  \/  | __ _(_)_ __  / /\ \
  161. -- | |\/| |/ _` | | '_ \| |  | |
  162. -- | |  | | (_| | | | | | |  | |
  163. -- |_|  |_|\__,_|_|_| |_| |  | |
  164. --                       \_\/_/
  165.  
  166. --
  167.  
  168.  
  169.  
  170. testFuel()
  171.  
  172. init()
  173. stop = false
  174. while(stop==false)do
  175.     checkIgniter()
  176.     checkIronBlock()
  177.     dropAll()
  178.     --sleep(1)
  179. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement