karelvysinka

EMP666 Turtle condenser machine 2017 prijmac

Aug 7th, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.98 KB | None | 0 0
  1. local version =
  2. 5.0
  3. -- EMP 666 - 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 = "DtHAXJSQ"
  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 aktuální")
  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.     turtla_label = os.getComputerLabel()
  46.     if message == "tr1sd" and turtla_label == "tr1" then
  47.         turtle.suckUp()
  48.         turtle.dropDown()
  49.     end
  50.  
  51.     if message == "alldrop" then
  52.         turtle.drop()
  53.     end
  54.     if message == "allsdd" then
  55.         turtle.suckDown()
  56.         turtle.drop()
  57.     end
  58.  
  59.     if message == "reboot" then
  60.         print("Rebootuji computer")
  61.         os.reboot()
  62.     end
  63.  
  64.     if message == "refuel" then
  65.         print("Turtla se natankovala uhlím na 64.")
  66.         turtle.select(1)
  67.         turtle.refuel(64)
  68.     end
  69.  
  70. print("Konec provadeni prikazu")
  71. end
  72.  
  73. start()
Add Comment
Please, Sign In to add comment