JustDoesGames

servers

Feb 13th, 2019
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. -- CLOUD BASED SYSTEM --
  2. --   SIMPLE VERSION   --
  3. -- BY JUST DOES GAMES --
  4.  
  5. cid = 0
  6. rednet.open("right")
  7.  
  8. function add(ffile, fn)
  9.     if fs.exists(fn) == true then fs.delete(fn) end
  10.     local file = fs.open(fn, "w")
  11.     file.write(ffile)
  12.     file.close()
  13. end
  14.  
  15. function send(ffile)
  16.     if fs.exists(file) == true then
  17.         local file = fs.open(ffile, "r")
  18.         rednet.send(cid, file.readAll())
  19.         file.close()
  20.     else
  21.         rednet.send(cid, "Cloud File Cannot be Found")
  22.     end
  23. end
  24.  
  25. shell.run("clear")
  26. print("Server ID: "..os.getComputerID())
  27. while true do
  28.     cid1, r = rednet.receive()
  29.     if r == "add" then
  30.         cid,wfile = rednet.receive()
  31.         if cid == cid1 then
  32.             cid,filename = rednet.receive()
  33.             if cid ~= nil then add(wfile,filename) end
  34.             print("Computer ID "..cid.." Added to Archive")
  35.         end
  36.     elseif r == "send" then
  37.         send(r)
  38.         print("Computer ID "..cid.." Requested an Archive")
  39.     end
  40. end
  41. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment