Advertisement
VincentDerJager

Vmail

Apr 17th, 2015
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.06 KB | None | 0 0
  1. --Variables
  2. _logo = paintutils.loadImage("vmail_logo")
  3. Space = " "
  4. from_string = "From: "
  5. Version = "Released"
  6. Last_Updated = "4/17/15"
  7.  
  8. --Functions
  9. function test()
  10. --Test for mouse functions
  11. term.setCursorPos(10,10)
  12. write("TEST")
  13. end
  14.  
  15. function update()
  16. local pastebinProgram = "pQgiZ5PT"
  17. local pastebinLogo = "1ncH36PP"
  18.  
  19. drawColors()
  20. fs.delete("vmail_logo")
  21. shell.run("pastebin", "get", pastebinLogo, "vmail_logo")
  22. fs.delete("vmail")
  23. shell.run("pastebin", "get", pastebinProgram, "vmail")
  24. end
  25.  
  26. function back()
  27. clean()
  28. draw()
  29. while true do
  30. parallel.waitForAny(listen, mouse_main)
  31. return
  32. end
  33. end
  34.  
  35. function new()
  36. --Start
  37. clean()
  38. drawColors()
  39. term.setCursorPos(45,1)
  40. write("[Quit]")
  41. term.setCursorPos(10,1)
  42. write("[Send]")
  43. term.setCursorPos(1,1)
  44. write("[Cancel]")
  45. term.setBackgroundColor(colors.cyan)
  46. term.setCursorPos(1,6)
  47. write("Message:")
  48. term.setCursorPos(1,4)
  49. write("From: ")
  50. term.setCursorPos(1,3)
  51. write("ID: ")
  52. term.setCursorPos(5,3)
  53. to_input = read()
  54. term.setCursorPos(7,4)
  55. from_input = read()
  56. term.setCursorPos(10,6)
  57. message_input = read()
  58. mouse_new()
  59. end
  60.  
  61. function mouse_new()
  62. while true do
  63. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  64. if _ms == 0 and button == 1 and xPos < 9 and yPos == 1 then
  65. back()
  66. end
  67.  
  68. if _ms == 0 and button == 1 and xPos < 16 and xPos > 8 and yPos == 1 then
  69. send()
  70. end
  71.  
  72. if _ms == 0 and button == 1 and xPos >= 45 and xPos <= 50 and yPos == 1 then
  73. quit()
  74. end
  75. end
  76. end
  77.  
  78. function mouse_bugs()
  79. while true do
  80. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  81. if _ms == 0 and button == 1 and xPos <= 6 and yPos == 1 then
  82. back()
  83. end
  84.  
  85. if _ms == 0 and button == 1 and xPos >= 8 and xPos <= 15 and yPos == 1 then
  86. email_bugs()
  87. end
  88. end
  89. end
  90.  
  91. function mouse_gen()
  92. while true do
  93. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  94. if _ms == 0 and button == 1 and xPos <= 7 and yPos == 1 then
  95. back()
  96. end
  97.  
  98. if _ms == 0 and button == 1 and xPos >= 45 and xPos <= 50 and yPos == 1 then
  99. quit()
  100. end
  101. end
  102. end
  103.  
  104. function mouse_help()
  105. while true do
  106. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  107. if _ms == 0 and button == 1 and xPos <= 7 and yPos == 1 then
  108. back()
  109. end
  110.  
  111. if _ms == 0 and button == 1 and xPos >= 45 and xPos <= 50 and yPos == 1 then
  112. quit()
  113. end
  114.  
  115. if _ms == 0 and button == 1 and xPos >= 1 and xPos <= 13 and yPos == 3 then
  116. email_bugs()
  117. end
  118. end
  119. end
  120.  
  121. function mouse_main()
  122. _ms = 0
  123. while true do
  124. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  125.  
  126. if _ms == 0 and button == 1 and xPos < 6 and yPos == 1 then
  127. new()
  128. end
  129.  
  130. if _ms == 0 and button == 1 and xPos >= 45 and xPos <= 50 and yPos == 1 then
  131. quit()
  132. end
  133.  
  134. if _ms == 0 and button == 1 and xPos >= 9 and xPos <= 15 and yPos == 1 then
  135. restart()
  136. end
  137.  
  138. if _ms == 0 and button == 1 and xPos >= 19 and xPos <= 28 and yPos == 1 then
  139. help()
  140. end
  141.  
  142. if _ms == 0 and button == 1 and xPos >= 28 and xPos <= 34 and yPos == 1 then
  143. bugs()
  144. end
  145.  
  146. if _ms == 0 and button == 1 and xPos >= 36 and xPos <= 50 and yPos == 19 then
  147. noticeboard()
  148. end
  149.  
  150. if _ms == 0 and button == 1 and xPos >= 36 and xPos <= 43 and yPos == 1 then
  151. clean()
  152. draw()
  153. while true do
  154. parallel.waitForAny(listen, mouse_main)
  155. end
  156. end
  157. end
  158. end
  159.  
  160. function mouse_email_bugs()
  161. _ms = 0
  162. while true do
  163. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  164. if _ms == 0 and button == 1 and xPos < 9 and yPos == 1 then
  165. back()
  166. end
  167.  
  168. if _ms == 0 and button == 1 and xPos < 16 and xPos > 8 and yPos == 1 then
  169. send_email()
  170. end
  171.  
  172. if _ms == 0 and button == 1 and xPos >= 45 and xPos <= 50 and yPos == 1 then
  173. quit()
  174. end
  175. end
  176. end
  177.  
  178. function clean()
  179. term.clear()
  180. term.setCursorPos(1,1)
  181. end
  182.  
  183. function listen()
  184. local counter = 2
  185. local Event, ID, Message, Distance = os.pullEvent("rednet_message")
  186. clean()
  187. draw()
  188. term.setCursorPos(1, 5)
  189. write("Sender's ID: " ..ID .."\n" ..Message)
  190. return
  191. end
  192.  
  193. function noticeboard()
  194. clean()
  195. drawColors()
  196. term.setCursorPos(45,1)
  197. write("[Quit]")
  198. term.setCursorPos(1,1)
  199. write("[Back]")
  200. term.setBackgroundColor(colors.cyan)
  201. term.setCursorPos(1,3)
  202. write("Sorry that it has been a long time since I have")
  203. term.setCursorPos(1, 4)
  204. write("updated this program.")
  205. term.setCursorPos(1, 5)
  206. write("I will try to get back into it.")
  207. term.setCursorPos(1,6)
  208. write("For those who question why I have been away")
  209. term.setCursorPos(1,7)
  210. write("I have been working on a game in C++ that will be")
  211. term.setCursorPos(1,8)
  212. write("on Steam and XBLA.")
  213. term.setCursorPos(1, 10)
  214. write(" VinCore Programs")
  215. mouse_gen()
  216. end
  217.  
  218. function help()
  219. clean()
  220. drawColors()
  221. term.setCursorPos(45,1)
  222. write("[Quit]")
  223. term.setCursorPos(1,1)
  224. write("[Back]")
  225. term.setBackgroundColor(colors.cyan)
  226. term.setCursorPos(1,3)
  227. write("[EMAIL DEVS]")
  228. mouse_help()
  229. end
  230.  
  231. function start()
  232. clean()
  233. drawColors()
  234. paintutils.drawImage(_logo, 10, 5)
  235. sleep(1)
  236. end
  237.  
  238. function quit()
  239. clean()
  240. drawColors()
  241. term.setCursorPos(1,1)
  242. write("Thank you for using VinCore Programs")
  243. sleep(1)
  244. os.reboot()
  245. end
  246.  
  247. function email_bugs()
  248. clean()
  249. drawColors()
  250. term.setCursorPos(45,1)
  251. write("[Quit]")
  252. term.setCursorPos(10,1)
  253. write("[Send]")
  254. term.setCursorPos(1,1)
  255. write("[Cancel]")
  256. term.setBackgroundColor(colors.cyan)
  257. term.setCursorPos(1,5)
  258. write("Message/Bug:")
  259. term.setCursorPos(1,4)
  260. write("Your Email: ")
  261. term.setCursorPos(1,3)
  262. write("From:")
  263. term.setCursorPos(7,3)
  264. from_email_input = read()
  265. term.setCursorPos(13, 4)
  266. email_from_user = read()
  267. term.setCursorPos(14,5)
  268. message_email_input = read()
  269. mouse_email_bugs()
  270. end
  271.  
  272. function bugs()
  273. clean()
  274. drawColors()
  275. term.setCursorPos(1,1)
  276. write("[Back]")
  277. term.setCursorPos(8,1)
  278. write("[Email]")
  279. term.setBackgroundColor(colors.cyan)
  280. term.setCursorPos(1,3)
  281. write("Please email us by click [Email] on the top of the screen!")
  282. term.setCursorPos(1,6)
  283. write("I will try to put out an update ASAP with that bug fixed if it is a major problem with the program.")
  284. term.setCursorPos(1,8)
  285. write("You may also ask any questions on this email.")
  286. term.setCursorPos(1,10)
  287. write("WARNING: If you abuse the email system it will be taken down.")
  288. term.setCursorPos(1,13)
  289. write("Thanks for reporting the bug!")
  290. mouse_bugs()
  291. end
  292.  
  293. function draw()
  294. clean()
  295. drawColors()
  296. term.setCursorPos(45,1)
  297. write("[Quit]")
  298. term.setCursorPos(1,1)
  299. write("[New]")
  300. term.setCursorPos(9, 1)
  301. write("[Reset]") --25
  302. term.setCursorPos(19, 1)
  303. write("[Help]")
  304. term.setCursorPos(28, 1)
  305. write("[Bugs]")
  306. term.setCursorPos(10,10)
  307. term.setCursorPos(36, 1)
  308. write("[Clear]") --7
  309. term.setCursorPos(36,19)
  310. write("[Notice Board]") --14
  311. term.setCursorPos(1,3)
  312. term.setBackgroundColor(colors.cyan)
  313. write("Mail: ")
  314. end
  315.  
  316. function restart()
  317. clean()
  318. shell.run("vmail")
  319. end
  320.  
  321. function send()
  322. Send_String = "From: " ..from_input .."\n" .."Message: " .."\n" .."\n" ..message_input
  323. sendingN = tonumber(to_input)
  324. rednet.send(sendingN, Send_String)
  325. clean()
  326. drawColors()
  327. term.setCursorPos(1,1)
  328. write("Message sent...")
  329. sleep(1)
  330. back()
  331. end
  332.  
  333. function send_email()
  334. email = "From: " ..from_email_input .. "\n" .."Email: " ..email_from_user.."\n" .."\n".."Bug/Message: " ..message_email_input
  335. http.post(
  336. "http://vincoreprograms.host22.com/vmail_bugs_email.php?message=" ..textutils.urlEncode(tostring(email))
  337. )
  338. clean()
  339. drawColors()
  340. term.setCursorPos(1,1)
  341. write("Bug/Message has been emailed to the developer!")
  342. sleep(1)
  343. back()
  344. end
  345.  
  346. function drawColors()
  347. paintutils.drawLine(1, 1, 100, 1, colors.blue)
  348. for i = 1,19 do
  349. i = i + 1
  350. paintutils.drawLine(1, i, 100, i, colors.cyan)
  351. end
  352. paintutils.drawLine(1, 19, 100, 19, colors.blue)
  353. term.setCursorPos(1,19)
  354. write("Last Updated: " ..Last_Updated)
  355. end
  356.  
  357. function main()
  358. update()
  359. start()
  360. clean()
  361. draw()
  362. while true do
  363. parallel.waitForAny(listen, mouse_main)
  364. end
  365. end
  366.  
  367. --Main
  368. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement