Advertisement
karelvysinka

Turtle ovladani vysilac

Jan 20th, 2017
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. local version =
  2. 11
  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 = "UWYuSLsV"
  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.  
  32.         print("Prikaz odeslan...")
  33.         print ("Program je aktualni...")
  34.         --print ("Program bezi...")
  35.         rednet.open("left")
  36.         --print ("Oteviram modem right.")
  37.         --print("Zadej prikaz: ")
  38.         local input = read()
  39.         --print("Odesilam prikaz:")
  40.         print(input)
  41.         print("..pres modem...")
  42.         rednet.broadcast(input)
  43.  
  44.     end
  45. end
  46.  
  47. function provedPrikaz(message)
  48.     if message == "turtledig" then
  49.         turtle.dig()
  50.     end
  51.    
  52.     if message == "reboot" then
  53.     print("Rebootuji computer")
  54.     os.reboot()
  55.     end
  56. print("Konec provadeni prikazu")
  57. end
  58.  
  59. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement