vincoreprograms

V-Mail_Test

Dec 23rd, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. --Variables
  2. _logo = paintutils.loadImage("vmail_logo")
  3. messageGUI = paintutils.loadImage("new_message_GUI")
  4. Space = " "
  5. from_string = "From: "
  6. message_string = "Message: "
  7. Version = "Developers: Beta 1.0"
  8.  
  9. --Functions
  10. function test()
  11. term.setCursorPos(10,10)
  12. write("TEST")
  13. end
  14.  
  15. function back()
  16. clean()
  17. draw()
  18. while true do
  19. parallel.waitForAny(listen, mouse_main)
  20. end
  21. end
  22.  
  23. function new()
  24. --Start
  25. clean()
  26. term.setBackgroundColor(512)
  27. term.setCursorPos(1,6)
  28. write("Message:")
  29. term.setCursorPos(45,1)
  30. write("[Quit]")
  31. term.setCursorPos(10,1)
  32. write("[Send]")
  33. term.setCursorPos(1,1)
  34. write("[Cancel]")
  35. term.setCursorPos(1,4)
  36. write("From: ")
  37. term.setCursorPos(1,3)
  38. write("To: ")
  39. term.setCursorPos(5,3)
  40. to_input = read()
  41. term.setCursorPos(7,4)
  42. from_input = read()
  43. term.setCursorPos(9,6)
  44. message_input = read()
  45. mouse_new()
  46. end
  47.  
  48. function mouse_new()
  49. while true do
  50. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  51. if _ms == 0 and button == 1 and xPos < 9 and yPos == 1 then
  52. back()
  53. end
  54.  
  55. if _ms == 0 and button == 1 and xPos < 16 and xPos > 8 and yPos == 1 then
  56. send()
  57. end
  58.  
  59. if _ms == 0 and button == 1 and xPos >= 45 and xPos <= 50 and yPos == 1 then
  60. quit()
  61. end
  62. end
  63. end
  64.  
  65. function mouse_bugs()
  66. _ms = 0
  67. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  68. while true do
  69. if _ms == 0 and button == 1 and xPos <= 6 and yPos == 1 then
  70. back()
  71. end
  72. end
  73. end
  74.  
  75. function mouse_help()
  76. while true do
  77. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  78. if _ms == 0 and button == 1 and xPos <= 7 and yPos == 1 then
  79. back()
  80. end
  81.  
  82. if _ms == 0 and button == 1 and xPos >= 45 and xPos <= 50 and yPos == 1 then
  83. quit()
  84. end
  85. end
  86. end
  87.  
  88. function mouse_main()
  89. _ms = 0
  90. while true do
  91. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  92. if _ms == 0 and button == 1 and xPos < 6 and yPos == 1 then
  93. new()
  94. end
  95.  
  96. if _ms == 0 and button == 1 and xPos >= 45 and xPos <= 50 and yPos == 1 then
  97. quit()
  98. end
  99.  
  100. if _ms == 0 and button == 1 and xPos >= 9 and xPos <= 16 and yPos == 1 then
  101. restart()
  102. end
  103.  
  104. if _ms == 0 and button == 1 and xPos >= 19 and xPos <= 27 and yPos == 1 then
  105. help()
  106. end
  107.  
  108. if _ms == 0 and button == 1 and xPos >= 28 and xPos <= 34 and yPos == 1 then
  109. bugs()
  110. end
  111.  
  112. end
  113. end
  114.  
  115. function clean()
  116. term.clear()
  117. term.setCursorPos(1,1)
  118. end
  119.  
  120. function help()
  121. clean()
  122. paintutils.drawLine(1,1,100,1,512)
  123. term.setCursorPos(45,1)
  124. write("[Quit]")
  125. term.setCursorPos(1,1)
  126. write("[Back]")
  127. term.setCursorPos(1,3)
  128. write("FAQ: ")
  129. term.setCursorPos(1,5)
  130. write("Q: 1. While making an E-mail why can't I hit cancel in the middle of making it?")
  131. term.setCursorPos(1,8)
  132. write("A: You have to finish making the E-Mail to cancel it because of the way it is coded.")
  133. term.setCursorPos(1,9)
  134. write("Q: 2. What do I enter for To?")
  135. term.setCursorPos(1,11)
  136. write("A: You enter the ID number for the computer you are trying to contact with.")
  137. term.setCursorPos(1,16)
  138. write("If you have anymore questions please report them in bugs!")
  139. mouse_help()
  140. end
  141.  
  142. function start()
  143. --rednet.open("back")
  144. term.setBackgroundColor(black)
  145. paintutils.drawImage(_logo, 10,5)
  146. sleep(1.2)
  147. clean()
  148. end
  149.  
  150. function quit()
  151. clean()
  152. write("Thank you for using VinCore Programs")
  153. sleep(1)
  154. os.reboot()
  155. end
  156.  
  157. function bugs()
  158. clean()
  159. term.setCursorPos(1,1)
  160. write("[Back]")
  161. term.setCursorPos(1,3)
  162. write("Please email: [email protected]")
  163. term.setCursorPos(1,5)
  164. write("I will try to put out an update ASAP with that bug fixed if it is a major problem with the program.")
  165. term.setCursorPos(1,7)
  166. write("You may also ask any questions on this email.")
  167. term.setCursorPos(1,9)
  168. write("Thanks for reporting the bug!")
  169. mouse_bugs()
  170. end
  171.  
  172. function draw()
  173. clean()
  174. term.setBackgroundColor(512)
  175. paintutils.drawLine(1,1,100,1,512)
  176. paintutils.drawLine(1,1,100,1,512)
  177. term.setCursorPos(45,1)
  178. write("[Quit]")
  179. term.setCursorPos(1,1)
  180. write("[New]")
  181. term.setCursorPos(9, 1)
  182. write("[Reset]") --25
  183. term.setCursorPos(19, 1)
  184. write("[Help]")
  185. term.setCursorPos(28, 1)
  186. write("[Bugs]")
  187. term.setCursorPos(10,10)
  188. term.setBackgroundColor(512)
  189. term.setCursorPos(1,3)
  190. write("Recent E-Mails: ")
  191. term.setCursorPos(32,19)
  192. write(Version)
  193. end
  194.  
  195. function restart()
  196. clean()
  197. shell.run("vmail")
  198. end
  199.  
  200. function send()
  201. Send_String = from_string ..from_input ..Space ..message_input
  202. sendingN = tonumber(to_input)
  203. rednet.send(sendingN, Send_String)
  204. clean()
  205. term.setBackgroundColor(8192)
  206. write("Message sent...")
  207. term.setCursorPos(1,3)
  208. sleep(1)
  209. back()
  210. end
  211.  
  212. function recieve()
  213. counter = 5
  214. while true do
  215. ID, Message = rednet.receive()
  216. term.setCursorPos(1,counter)
  217. write(Message)
  218. end
  219. end
  220.  
  221. function listen()
  222. counter = 5
  223. ID, Message = rednet.receive()
  224. counter = counter + 1
  225. term.setCursorPos(1, counter)
  226. write(Message)
  227. end
  228.  
  229. function main()
  230. clean()
  231. start()
  232. draw()
  233. while true do
  234. parallel.waitForAny(listen, mouse_main)
  235. end
  236. end
  237.  
  238. --Main
  239. main()
Advertisement
Add Comment
Please, Sign In to add comment