Advertisement
Marlingaming

Email Based Item Digital Transmitter and Receiver

Sep 13th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. --this program acts as a email based item transfer system
  2. local BaseProtocol = 0
  3. local HostName = 0
  4. local Username = 'n'
  5.  
  6.  
  7.  
  8.  
  9.  
  10. start()
  11.  
  12. function start()
  13. term.setCursorPos(1,1)
  14. print("-----Electronic-Mail-Based-Transfer-System------")
  15. print("welcome! Please wait until prompt appears")
  16. CheckUpdates()
  17.  
  18. end
  19.  
  20. function CheckUpdates()
  21. rednet.open()
  22. local id = rednet.lookup(BaseProtocol, "SYS_MAN_01")
  23. local ServerID = id
  24. repeat
  25. local id, message, protocol = rednet.receive()
  26. until id == ServerID and protocol == BaseProtocol
  27. if message == "Update" then
  28. rednet.send(ServerID,"Details",BaseProtocol)
  29. repeat
  30. local id, message = rednet.receive()
  31. until id == ServerID
  32. local MFile = fs.open("UpdateFile","w")
  33. MFile.clear()
  34. MFile.setCursorPos(1,1)
  35. MFile.write(message)
  36. MFile.close()
  37. shell.run("UpdateFile")
  38. elseif message == "n" then
  39. Login()
  40. end
  41. end
  42.  
  43. function Login()
  44. print("Please Enter Username")
  45. local input = read()
  46. while true do
  47. local event, key = os.pullEvent("key")
  48. if key == keys.enter then
  49. Username = input
  50. break
  51. end
  52. end
  53. Menu()
  54. end
  55.  
  56. function Menu()
  57. term.clear()
  58. term.setCursorPos(1,1)
  59. print("Wecome, "..Username)
  60. print("Options")
  61. print("1 = Received")
  62. print("2 = Send")
  63. print("3 = Logout")
  64. repeat
  65. local input = read()
  66. until input == 1 or input == 2 or input == 3
  67. if input == 1 then
  68. AccountItems()
  69. elseif input == 2 then
  70. MailMenu()
  71. elseif input == 3 then
  72. os.reboot()
  73. end
  74. end
  75.  
  76. function AccountItems()
  77. rednet.open()
  78. local id = rednet.lookup(BaseProtocol, "Accounts_Data")
  79. HostName = id
  80. rednet.send(id,Username,BaseProtocol)
  81. repeat
  82. local id, message, protocol
  83. until protocol == BaseProtocol and id == HostName
  84. print("--Items in Storage--")
  85. print(message)
  86. print("---Please Press e to download, or q to go to menu--")
  87. repeat
  88. local event, key = os.pullEvent("key")
  89. until key == keys.e or key == keys.q
  90. if key == Keys.e then
  91. DownloadItems()
  92. elseif key == keys.q then
  93. Menu()
  94. end
  95. end
  96.  
  97. function DownloadItems()
  98.  
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement