karelvysinka

EX600 Turtle digator 2017

Aug 7th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. local version =
  2. 4.0
  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 = "skei2DRP"
  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 is actual..")
  32.         print ("Program working...")
  33.         rednet.open("right")
  34.         print ("Open modem right.")
  35.  
  36.         print("Help:")
  37.         print("alldrop - all turtle drop slot.")
  38.         print("allsdd - all turtle suck down and drop.")
  39.         print("reboot - all turtle reboot.")
  40.  
  41.         print("Your command: ")
  42.         local input = read()
  43.         print("sending a command...:")
  44.         print(input)
  45.         print("..connect modem...")
  46.         rednet.broadcast(input)
  47.         print("Command sent OK...")
  48.     end
  49. end
  50.  
  51. function provedPrikaz(message)
  52.     if message == "td" then
  53.         turtle.dig()
  54.     end
  55.    
  56.     if message == "reboot" then
  57.     print("Reboot computer...")
  58.     os.reboot()
  59.     end
  60. print("End command...")
  61. end
  62.  
  63. start()
Add Comment
Please, Sign In to add comment