Don't like ads? PRO users don't see any ads ;-)
Guest

storeserver

By: a guest on May 4th, 2012  |  syntax: Lua  |  size: 0.96 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. rednet.open("back")
  2. os.loadAPI("split")
  3. print("Google Store Server")
  4. print("Please put the wireless modem on the back.")
  5. t = {"downloads","downloads/info","downloads/files"}
  6. for i = 1, 3 do
  7. if (fs.exists(t[i])) then
  8. print(t[i].." found!")
  9. else
  10. print(t[i].." not found. Creating...")
  11. fs.makeDir(t[i])
  12. end
  13. end
  14. print("Google Store Server Initialized!")
  15. while true do
  16. local id, msg = rednet.receive()
  17. msg = split(msg,":")
  18. if (msg[1] == "store_ping") then
  19. print(id.." is requesting download list.")
  20. local list = "Download list...\n" + table.concat(fs.list("downloads/files"))
  21. rednet.send(id,"list:"+list)
  22. elseif (msg[1] == "download") then
  23. print(id.." is wanting to download "..msg[2].."!")
  24. if (fs.exists("downloads/files/"..msg[2])) then
  25. print("downloads/files/"..msg[2].." exists!")
  26. link = fs.open("downloads/files/"..msg[2],"r")
  27. rednet.send(id,link.readAll())
  28. link.close()
  29. else
  30. rednet.send(id,"existerror")
  31. print(msg[2].." doesn't exist!")
  32. end
  33. end
  34. end