SVty

Farming turtle

Feb 17th, 2013
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. --Program pro farmici zelvu pro farmareni
  2. --Verze programu beta 0.8.1
  3. --vytvoril SVty
  4. --*****************************
  5.  
  6. print("Napiste delku farmy:")
  7. delka = (read())
  8. print("Delka farmy je "..delka.. " kostek")
  9. print("Zadejte sirku farmy:")
  10. sir = (read())
  11. print("Sirka farmy je "..sir.." kostek")
  12. sir = sir /2
  13. sleep(1)
  14.  
  15. function palivo()
  16.   if (turtle.getFuelLevel()) < 20 then
  17.     turtle.select(16)
  18.     turtle.refuel(4)
  19.     turtle.select(1)
  20.     print("doplnuji palivo")
  21.   end
  22. end
  23.  
  24. palivo()
  25. if (turtle.detectDown()) then
  26.   turtle.up()
  27.   turtle.forward()
  28. else
  29.   turtle.forward()
  30. end
  31.  
  32. function left()
  33. turtle.turnLeft()
  34. turtle.forward()
  35. turtle.turnLeft()
  36. turtle.forward()
  37. end
  38.  
  39. function right()
  40. turtle.turnRight()
  41. turtle.forward()
  42. turtle.turnRight()
  43. turtle.forward()
  44. end
  45.  
  46. function farm()
  47.   for del=1,delka do
  48.     turtle.digDown()
  49.     turtle.digDown()
  50.     turtle.select(1)
  51.     turtle.placeDown()
  52.     turtle.forward()
  53.     del = del + 1
  54.     print(del)
  55.     palivo()
  56.   end  
  57. end
  58.  
  59. function retu()
  60.   sir = sir *2
  61.   turtle.turnLeft()
  62.     for c=1,sir do
  63.     turtle.forward()
  64.     end
  65.   turtle.turnLeft()
  66.   turtle.forward()
  67.   turtle.turnLeft()
  68.   turtle.turnLeft()
  69. end
  70.  
  71. --program
  72. for d=1,sir do
  73.   farm()
  74.   right()
  75.   farm()
  76.   left()
  77. end
  78. --program
  79.  
  80. retu()
  81. print("HOTOVO")
Advertisement
Add Comment
Please, Sign In to add comment