Guest User

updater

a guest
Oct 11th, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. rednet.open("right")
  2.  
  3. function checkTags(toCheck)
  4.   comon = 0
  5.   for i=1,#toCheck do
  6.     for o=1,#tags do
  7.       if tags[o] == toCheck[i] then
  8.         comon = comon + 1
  9.       end
  10.     end
  11.   end
  12.   if comon >= #toCheck then
  13.     return true
  14.   else
  15.     return false
  16.   end
  17. end
  18.  
  19. function checkUpdate()
  20.   local id, local func, local tags, local filename, local filedata = rednet.receive()
  21.   if type(tags) == "table" then
  22.     if checkTags(tags) then
  23.       if func == "Update" then
  24.         file = fs.open(filename, "w")
  25.         file.write(filedata)
  26.         file.close()
  27.       elseif func == "Delete" then
  28.         fs.delete(filename)
  29.       elseif func == "Shutdown" then
  30.         os.shutdown()
  31.       end
  32.     end
  33.   end
  34. end
  35.  
  36. while true do
  37.   checkUpdate()
  38. end
Advertisement
Add Comment
Please, Sign In to add comment