Advertisement
sinkir

lua turtle NagaStoneFarm

Oct 20th, 2014
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.82 KB | None | 0 0
  1. -- pastebin get 4WJAYH7n farm
  2. -- -------------------------------------------
  3. -- NagaStoneFarm -Sinkir-
  4. -- Version 0.1 (2014/10/21)
  5.  
  6. -- SCANER FUNCTION :
  7. -- slot 16 ender chest Fuel               +-+-+-+-+
  8. -- slot 15 ender chest dump Resources     | | | | |
  9. --                                        | | | | |
  10. --                                        | | | | |
  11. --                                        | | |R|F|
  12. --                                        +-+-+-+-+
  13. -- -------------------------------------------
  14.  
  15.  
  16.  
  17. --   _____
  18. --  |  ___|   _ _ __   ___
  19. --  | |_ | | | | '_ \ / __|
  20. --  |  _|| |_| | | | | (__
  21. --  |_|   \__,_|_| |_|\___|
  22. --
  23.  
  24.  
  25.  
  26. function testFuel()
  27.     if(fuel() < 1)then
  28.         select(16)
  29.         turtle.refuel()
  30.     end
  31.     if(count(16) == 0)then
  32.         return false
  33.     end
  34.     return true
  35. end
  36.  
  37.  
  38. left = function()
  39.     if(turtle.turnLeft()==false)then
  40.         sleep(1)
  41.         left()
  42.     else
  43.         return true
  44.     end
  45. end
  46. right = function()
  47.     if(turtle.turnRight()==false)then
  48.         sleep(1)
  49.         right()
  50.     else
  51.         return true
  52.     end
  53. end
  54. count = function(id)
  55.     return turtle.getItemCount(id)
  56. end
  57. back = function()
  58.     return turtle.back()
  59. end
  60. go = function()
  61.     return turtle.forward()
  62. end
  63. select = function(id)
  64.     return turtle.select(id)
  65. end
  66. fuel = function()
  67.     return turtle.getFuelLevel()
  68. end
  69. move = function(id, nb)
  70.     return turtle.transferTo(id, nb)
  71. end
  72. --
  73. --
  74.  
  75.  
  76. --
  77. --
  78.  
  79.  
  80.  
  81. function checkSlotVideScaner()
  82.     if(count(6) == 0 and count(7) == 0)then
  83.         return true
  84.     end
  85.     return false
  86. end
  87.  
  88.  
  89.  
  90. function videInv()
  91.     if(count(12) == 0 and count(13) == 0 and count(14) == 0)then
  92.         return true
  93.     end
  94.     local i = 0
  95.     select(15)
  96.     turtle.digUp()
  97.     turtle.placeUp()
  98.  
  99.     for i=1,14 do
  100.         if(count(i)>0)then
  101.             select(i)
  102.             turtle.dropUp()
  103.         end
  104.     end
  105.     select(15)
  106.     turtle.digUp()
  107.     return true
  108. end
  109.  
  110.  
  111.  
  112. function initScan()
  113.     if(count(16) == 0)then
  114.         print("No ender chest for fuel in slot 16.., exit")
  115.         return false
  116.     end
  117.     if(count(15) == 0)then
  118.         print("No ender chest for dump resources in slot 15, exit")
  119.         return false
  120.     end
  121.  
  122.     return true
  123. end
  124.  
  125.  
  126.  
  127. function gps()
  128.     select(1)
  129.    
  130.    
  131.     if(turtle.detect() == false and turtle.detectUp() == false and turtle.detectDown() == false)then
  132.         back()
  133.         right()
  134.         if(turtle.detect() == false and turtle.detectUp() == false and turtle.detectDown() == false)then
  135.             print('exit')
  136.             stop=true
  137.         end
  138.     end
  139.    
  140.     if(turtle.detect())then
  141.         turtle.dig()
  142.     end
  143.     if(turtle.detectUp())then
  144.         turtle.digUp()
  145.     end
  146.     if(turtle.detectDown())then
  147.         turtle.digDown()
  148.     end
  149.     go()
  150.  
  151. end
  152.    
  153.  
  154.  
  155. --  __  __       _        ____
  156. -- |  \/  | __ _(_)_ __  / /\ \
  157. -- | |\/| |/ _` | | '_ \| |  | |
  158. -- | |  | | (_| | | | | | |  | |
  159. -- |_|  |_|\__,_|_|_| |_| |  | |
  160. --                       \_\/_/
  161.  
  162.  
  163.  
  164.  
  165. stop=false
  166.  
  167. i = 0
  168. stopCounter = 1
  169. while(stop==false)do
  170.    
  171.    
  172.     testFuel()
  173.     gps()
  174.     videInv()
  175.  
  176.     sleep(0.2)
  177. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement