Advertisement
Kar27

email clent

Sep 6th, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.51 KB | None | 0 0
  1. --[[ Config File ]]--
  2. IDserver = 11 --[[ The server that this computer is gona use for send messages
  3. IMPORTANT: 2 Computers cant use the same server! ]]--
  4. IDcomputer = "7" --[[ For check the ID of this computer, start the mail program
  5. and check it at top right of the screen. ]]--
  6. modem = "back" --[[ Where the modem is at?
  7. (front, back, top, bottom, right, left) ]]--
  8.  
  9. --[[ End of Config ]]--
  10.  
  11. --[[ Start of program ]]--
  12. generalloop = true
  13. while (generalloop == true) do
  14. sleep(0.1)
  15. rednet.open(modem)
  16. term.clear()
  17. term.setCursorPos(45,1)
  18. Start = "ID: "
  19. ID = os.computerID()
  20. End = " \n"
  21. Start = Start..ID
  22. write(Start..End)
  23. term.setCursorPos(1,1)
  24. print "Mail Menu"
  25. print "-------------------------"
  26. print "1. Send Message"
  27. print "2. Look for new messages"
  28. print "3. Disconnect"
  29. print "-------------------------"
  30. write "Please select an option: "
  31. input = read()
  32. if (input == "1") then
  33. SMloop = true
  34. while (SMloop == true) do
  35. term.clear()
  36. term.setCursorPos(1,1)
  37. print "Send Message"
  38. print "---------------"
  39. write "To: "
  40. to = read()
  41. write "Message: "
  42. message = read()
  43. print "---------------"
  44. print ""
  45. print "Sending Message..."
  46. sleep(2)
  47. if (to == "") or (message == "") then
  48. term.clear()
  49. term.setCursorPos(1,1)
  50. print "Message Failed"
  51. print "-----------------------------"
  52. print "Please fill all the fields"
  53. sleep(2)
  54. else
  55. SMloop = false
  56. term.clear()
  57. term.setCursorPos(1,1)
  58. rednet.send(IDserver, message)
  59. rednet.send(IDserver, to)
  60. rednet.send(IDserver, IDcomputer)
  61. server, msg = rednet.receive()
  62. end
  63. end
  64. if (msg == "Message Recived") then
  65. print "Message Sent"
  66. print "---------------------------------------"
  67. print("To: " .. to)
  68. print("Message: " .. message)
  69. print "---------------------------------------"
  70. print "The message has been sent to the server"
  71. print "As soon as the computer"
  72. print "that you sended refreshes"
  73. print "the new messages, he will recive your"
  74. print "email."
  75. print ""
  76. print "NOTE: If you did not enter any computer"
  77. print " ID, the message it will never be"
  78. print " recived by anyone!"
  79. print "---------------------------------------"
  80. print "(Press B for go back)"
  81. backloop = true
  82. while (backloop == true) do
  83. local sBack, back = os.pullEvent("key")
  84. if (sBack == "key") then
  85. if (back == 48) then
  86. break
  87. end
  88. end
  89. end
  90. elseif (msg == "Error") then
  91. term.clear()
  92. term.setCursorPos(1,1)
  93. print "Error: Message not sent"
  94. print "-------------------------"
  95. print "Something went wrong!"
  96. print "Please try it again."
  97. print "Remember to put a valid"
  98. print "destination!"
  99. print ""
  100. print "Ex:"
  101. print "To: 6"
  102. print "-------------------------"
  103. print "(Press B for go back)"
  104. backloop = true
  105. while (backloop == true) do
  106. local sBack, back = os.pullEvent("key")
  107. if (sBack == "key") then
  108. if (back == 48) then
  109. break
  110. end
  111. end
  112. end
  113. end
  114.  
  115. elseif (input == "2") then
  116. term.clear()
  117. term.setCursorPos(1,1)
  118. print "Looking for new messages"
  119. print "-------------------------------------"
  120. print "Asking the server for new messages..."
  121. print ""
  122. print "This can take a while, please wait."
  123. from, senderMsg, distance = rednet.receive(30)
  124. from, sendby, distance = rednet.receive(2)
  125. if (senderMsg ~= nil) then
  126. if (sendby ~= nil) then
  127. rednet.send(from, "Recived")
  128. term.clear()
  129. term.setCursorPos(1,1)
  130. print "Message Recived"
  131. print "------------------------------"
  132. print("From: " ..sendby)
  133. print ""
  134. print("Message: " ..senderMsg)
  135. print "------------------------------"
  136. print "(Press B for go back)"
  137. backloop = true
  138. while (backloop == true) do
  139. local sBack, back = os.pullEvent("key")
  140. if (sBack == "key") then
  141. if (back == 48) then
  142. break
  143. end
  144. end
  145. end
  146. else
  147. term.clear()
  148. term.setCursorPos(1,1)
  149. print "No new messages recived"
  150. print ""
  151. print "(Press B for go back)"
  152. backloop = true
  153. while (backloop == true) do
  154. local sBack, back = os.pullEvent("key")
  155. if (sBack == "key") then
  156. if (back == 48) then
  157. break
  158. end
  159. end
  160. end
  161. end
  162. end
  163. elseif (input == "3") then
  164. generalloop = false
  165. term.clear()
  166. term.setCursorPos(1,1)
  167. print "Disconecting..."
  168. print "------------------"
  169. print "Disconnected!"
  170. print ""
  171. print "(Press Q for quit)"
  172. rednet.close(modem)
  173. quitloop = true
  174. while (quitloop == true) do
  175. local sQuit, quit = os.pullEvent("key")
  176. if (sQuit == "key") then
  177. if (quit == 16) then
  178. break
  179. end
  180. end
  181. end
  182. sleep(0.1)
  183. term.clear()
  184. term.setCursorPos(1,1)
  185. else
  186. print ""
  187. print "Unknown option!"
  188. print "Please try again."
  189. sleep(3)
  190. end
  191. end
  192. --[[ End of program ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement