Advertisement
karelvysinka

Turtle prijmac dig ender 1

Feb 8th, 2017
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.35 KB | None | 0 0
  1. local version =
  2. 5.1
  3. -- Program pro prijem zprav pres modem
  4. -- Pri zmene programu je treba na radku 2 zmenit verzi, aby se program automaticky aktualizoval
  5. -- local code je treba zmenit dle potreby
  6.  
  7. local code = "5rTHHRhE"
  8.  
  9. --check version
  10. term.clear()
  11. term.setCursorPos(1,1)
  12. print("Program loading...")
  13. print("Current version: "..version)
  14. local updateSite= http.get("http://pastebin.com/raw.php?i="..code)
  15. updateSite.readLine()
  16. local newVersion = updateSite.readLine()
  17. if tonumber(newVersion) > version then
  18.         print("Update required. Updating now...")
  19.         local updateSite = http.get("http://pastebin.com/raw.php?i="..code)
  20.         local siteFile = updateSite.readAll()
  21.         local writeFile = fs.open(shell.getRunningProgram(),"w")
  22.         writeFile.write(siteFile)
  23.         writeFile.close()
  24.         print("The program will now restart your computer.")
  25.         sleep(1)
  26.         os.reboot()
  27. end
  28.  
  29. function start()
  30.     while true do
  31.         print ("Program je aktualni")
  32.         print ("Program bezi...")
  33.         rednet.open("right")
  34.         print ("Oteviram medem right.")
  35.         print("Cekam na zpravu...")
  36.         id, message  = rednet.receive(10000000000000)
  37.         print ("Computer ".. id .. " has sent us a message")
  38.         print ("The message is")
  39.         print (message)
  40.         provedPrikaz(message)
  41.     end
  42. end
  43.  
  44. function provedPrikaz(message)
  45.     if message == "tankuj" then
  46.         turtle.suckDown()
  47.         turtle.refuel()
  48.         turtle.suckDown()
  49.         turtle.refuel()
  50.     end
  51.     if message == "tez" then
  52.         turtle.dig()
  53.         while turtle.detect() == true do
  54.             turtle.dig()
  55.         end
  56.         turtle.forward()
  57.         turtle.digUp()
  58.         turtle.digDown()
  59.         turtle.dig()
  60.         while turtle.detect() == true do
  61.             turtle.dig()
  62.         end
  63.     end
  64.  
  65.     if message == "vyp" then
  66.         turtle.select(1)
  67.         turtle.placeDown()
  68.         turtle.select(2)
  69.         turtle.dropDown(64)
  70.         turtle.select(3)
  71.         turtle.dropDown(64)
  72.         turtle.select(4)
  73.         turtle.dropDown(64)
  74.         turtle.select(5)
  75.         turtle.dropDown(64)
  76.         turtle.select(6)
  77.         turtle.dropDown(64)
  78.         turtle.select(7)
  79.         turtle.dropDown(64)
  80.         turtle.select(8)
  81.         turtle.dropDown(64)
  82.         turtle.select(9)
  83.         turtle.dropDown(64)
  84.         turtle.select(10)
  85.         turtle.dropDown(64)
  86.         turtle.select(11)
  87.         turtle.dropDown(64)
  88.         turtle.select(12)
  89.         turtle.dropDown(64)
  90.         turtle.select(13)
  91.         turtle.dropDown(64)
  92.         turtle.select(14)
  93.         turtle.dropDown(64)
  94.         turtle.select(15)
  95.         turtle.dropDown(64)
  96.         turtle.select(16)
  97.         turtle.dropDown(64)
  98.  
  99.         sleep(16)
  100.         turtle.digDown()
  101.     end
  102.    
  103.     if message == "dig" then
  104.         turtle.dig()
  105.     end
  106.    
  107.     if message == "d" then
  108.         turtle.dig()
  109.     end
  110.  
  111.     if message == "reboot" then
  112.         print("Rebootuji computer")
  113.         os.reboot()
  114.     end
  115.  
  116.     if message == "digUp" then
  117.         print("Tento prikaz bude osetren, aby se nerobila Turtla nad turtlou. Zatim nefunguje.")
  118.         --zde je treba napsat osetreni proti zniceni turtly nad
  119.         --turtle.digUp()
  120.     end
  121.    
  122.     if message == "forward" then
  123.         print("Turtla jede dopredu.")
  124.         turtle.forward()
  125.     end
  126.  
  127.     if message == "f" then
  128.         print("Turtla jede dopredu.")
  129.         turtle.forward()
  130.     end
  131.  
  132.     if message == "back" then
  133.         print("Turtla jede dozadu.")
  134.         turtle.back()
  135.     end
  136.  
  137.     if message == "up" then
  138.         print("Turtla jede nahoru.")
  139.         turtle.up()
  140.     end
  141.  
  142.     if message == "turnleft" then
  143.         print("Turtla se otocila doleva.")
  144.         turtle.turnLeft()
  145.     end
  146.  
  147.     if message == "turnright" then
  148.         print("Turtla se otocila doprava.")
  149.         turtle.turnRight()
  150.     end
  151.  
  152.     if message == "refuel" then
  153.         print("Turtla se natankovala uhlim na 64.")
  154.         turtle.select(1)
  155.         turtle.refuel(64)
  156.     end
  157.  
  158.     if message == "refuel2" then
  159.         print("Turtla se natankovala z 2 slotu uhlim na 64.")
  160.         turtle.select(2)
  161.         turtle.refuel(64)
  162.     end
  163.  
  164.     if message == "drop" then
  165.         print("Turtl upustila 64 itemu.")
  166.         turtle.drop(64)
  167.     end
  168.  
  169. print("Konec provadeni prikazu")
  170. end
  171.  
  172. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement