SVty

Farming Turtle

Apr 4th, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.87 KB | None | 0 0
  1. --Program pro farmici zelvu pro farmareni
  2. --Verze programu beta 1.0.6
  3. --vytvoril SVty
  4. --www.youtube.com/SVtyPlay
  5. --www.pastebin.com/u/SVty
  6. --*****************************
  7. term.clear()
  8. term.setCursorPos(1,1)
  9. print("Tento program slouzi pro farmareni")
  10. print("----------------------------------")
  11. print("Osivo rozlozte do slotu jedna az ctyri (bude slouzit i jako predloha)")
  12. print("Do 16. slotu vlozte palivo. Bude samovolne odebirano dle potreby")
  13. print("----------------------------------")
  14. print("Napiste delku farmy:")
  15. delka = (read())
  16. print("Zadejte sirku farmy:")
  17. sir = (read())
  18. sir = sir /2
  19. sir = math.floor(sir)
  20. sem = true
  21. slot = 1
  22. rada = 0
  23. d = 1
  24. zp = 0
  25. sleep(1)
  26.  
  27. --Graphical User Interface
  28.     term.clear()
  29.     term.setCursorPos(1,1)
  30.     print("Program pro farmareni")
  31.     term.setCursorPos(1,2)
  32.     print("----------------------------------")
  33.     term.setCursorPos(1,3)
  34.     print("Delka farmy je "..delka.. " kostek")
  35.     term.setCursorPos(1,4)
  36.     print("Sirka farmy je "..(sir * 2).." kostek")
  37.     term.setCursorPos(27,3)
  38.     print("Plocha:")
  39.     term.setCursorPos(27,4)
  40.     print(delka * (sir * 2).." kostek")
  41.     term.setCursorPos(1,5)
  42.     print("----------------------------------")
  43.     term.setCursorPos(1,6)
  44.     print("Stav paliva:")
  45.     print("Dokonceno rad:")
  46.     term.setCursorPos(17,6)
  47.     print(tostring(turtle.getFuelLevel()))
  48.     term.setCursorPos(17,7)
  49.     print("0 / "..(sir * 2))
  50.    
  51.    
  52. --konec Graphical User Interface
  53.  
  54. function palivo()
  55.   if (turtle.getFuelLevel()) < 10 then
  56.     turtle.select(16)
  57.     while not turtle.refuel(1) do
  58.       sleep(1)
  59.       term.setCursorPos(1,10)
  60.       print("                  ")
  61.       term.setCursorPos(1,10)
  62.       print("Vlozte palivo")
  63.     end
  64.     turtle.select(slot)
  65.     term.setCursorPos(1,10)
  66.     print("                  ")
  67.     term.setCursorPos(1,10)
  68.     print("Doplnuji palivo")
  69.   end
  70. end
  71.  
  72. function move()
  73.   while not turtle.forward() do
  74.     sleep(1)
  75.     term.setCursorPos(1,11)
  76.     print("Uvolnete cestu!")
  77.   end
  78.   term.setCursorPos(1,11)
  79.   print("               ")
  80. end
  81.  
  82. function left()
  83.   if zp < sir then
  84.     turtle.turnLeft()
  85.     turtle.dig()
  86.     move()
  87.     turtle.turnLeft()
  88.     turtle.dig()
  89.     move()
  90.   end
  91. end
  92.  
  93. function right()
  94.     turtle.turnRight()
  95.     turtle.dig()
  96.     move()
  97.     turtle.turnRight()
  98.     turtle.dig()
  99.     move()
  100. end
  101.  
  102. function drop()
  103.   if turtle.detect() then
  104.     for sd=5,15 do
  105.       turtle.select(sd)
  106.       turtle.drop()
  107.     end
  108.   end
  109. end
  110.  
  111. function farm()
  112.   rada = rada + 1
  113.   turtle.select(slot)  
  114.   for i=1,delka do
  115.     if sem == true then
  116.       if turtle.getItemCount(slot) == 1 then
  117.         slot = slot + 1
  118.         if slot == 5 then
  119.           slot = 1
  120.           term.setCursorPos(1,8)
  121.           print("Nedostatek osiva!")
  122.           sem = false
  123.         end
  124.         turtle.select(slot)
  125.       end
  126.     else
  127.       turtle.select(1)
  128.       term.setCursorPos(1,9)
  129.       print("Pouze okopavam")
  130.     end
  131.       turtle.dig()
  132.       turtle.digDown()
  133.       turtle.digDown()
  134.       if turtle.getItemCount(slot) > 1 then
  135.         turtle.placeDown()
  136.       end
  137.       palivo()
  138.       move()
  139.         term.setCursorPos(17,6)
  140.         print(tostring(turtle.getFuelLevel()))
  141.     end
  142.     term.setCursorPos(17,7)
  143.     print(rada.." / "..(sir * 2))
  144. end
  145.  
  146. function retu()
  147.   sir = sir *2
  148.   turtle.turnRight()
  149.   for c=1,(sir-1) do
  150.     move()
  151.   end
  152.   turtle.turnLeft()
  153.   drop()
  154.   turtle.turnRight()
  155.   turtle.turnRight()
  156. end
  157.  
  158.  
  159. --program
  160. palivo()
  161. if (turtle.detectDown()) then
  162.   while not turtle.up() do
  163.     sleep(1)
  164.     term.setCursorPos(1,11)
  165.     print("Uvolnete cestu!")
  166.   end
  167.   turtle.dig()
  168.   move()
  169. else
  170.   turtle.dig()
  171.   move()
  172. end
  173.  
  174. for d=1,sir do
  175.   zp = zp + 1
  176.   farm()
  177.   right()
  178.   farm()
  179.   left()
  180. end
  181. retu()
  182. --konec program
  183.  
  184. term.setCursorPos(1,10)
  185. print("----------------------------------")
  186. print("HOTOVO")
Advertisement
Add Comment
Please, Sign In to add comment