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

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 1.06 KB  |  hits: 18  |  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. --Send format: <key>:<send>:<from>:<to>:<message>
  2. -- Number format 1      2     3      4      5
  3. --Receive format <key>:<receive>
  4. -- Number format   1      2
  5. rednet.open("back")
  6. term.clear()
  7. term.setCursorPos(1,1)
  8. print("RFSA Voennaya sistema elektronnoi pochty")
  9. while true do
  10. id,msg = rednet.receive()
  11. split(msg,":")
  12. if msg[1]=="nikkita" then
  13. if msg[2]=="send" then
  14. idFrom = msg[3]
  15. idTo = msg[4]
  16. x = fs.open(msg[4],"w")
  17. w.writeLine("From:")
  18. w.writeLine(msg[3])
  19. w.writeLine(msg[5])
  20. x.close()
  21. end
  22. if msg[2]=="receive" then
  23. x = fs.exists(id)
  24. if x=="true" then
  25. y = fs.open(id,"r")
  26. rednet.send(id,y)
  27. end
  28. if x=="false" then
  29. rednet.send(id,"false")
  30. end
  31. end
  32. end
  33. end
  34.  
  35. function split(pString, pPattern)
  36. local Table = {}
  37. local fpat = "(.-)" .. pPattern
  38. local last_end = 1
  39. local s, e, cap = pString:find(fpat, 1)
  40. while s do
  41. if s ~= 1 or cap ~= "" then
  42. table.insert(Table,cap)
  43. end
  44. last_end = e+1
  45. s, e, cap = pString:find(fpat, last_end)
  46. end
  47. if last_end <= #pString then
  48. cap = pString:sub(last_end)
  49. table.insert(Table, cap)
  50. end
  51. return Table
  52. end