paramus

EmailClient

Mar 30th, 2026 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.76 KB | Gaming | 0 0
  1. local User = ""
  2. local Emails = {{From="From", Subject="Subject", Content="Content"}, {From="Cesar", Subject="New program", Content="ContentContentContentContentContent"}}
  3.  
  4. function main()
  5.     PageLogin()
  6. end
  7.  
  8. function PageLogin()
  9.     User = ""
  10.     local Password = ""
  11.     while (true) do
  12.         --Paint
  13.         term.setBackgroundColor(colors.white)
  14.         term.setTextColor(colors.black)
  15.         term.clear()
  16.        
  17.         term.setCursorPos(23,2)
  18.         print("E-MAIL")
  19.         paintutils.drawFilledBox(19, 5, 32, 14, colors.yellow)
  20.        
  21.         term.setCursorPos(20,6)
  22.         print("User:")
  23.         term.setCursorPos(20,9)
  24.         print("Password:")
  25.        
  26.         term.setCursorPos(20,12)
  27.         term.setTextColor(colors.blue)
  28.         print("New account?")
  29.        
  30.         paintutils.drawLine(20, 7, 31, 7, colors.black)
  31.         paintutils.drawLine(20, 10, 31, 10, colors.black)
  32.        
  33.         paintutils.drawFilledBox(22, 16, 29, 18, colors.green)
  34.         term.setCursorPos(23,17)
  35.         term.setTextColor(colors.white)
  36.         print("Log In")
  37.        
  38.         paintutils.drawPixel(20, 7, colors.black)
  39.         term.setCursorPos(20,7)
  40.         term.setTextColor(colors.white)
  41.         print(User)
  42.        
  43.         local secret = ""
  44.         for i = 1,string.len(Password) do
  45.             secret = secret .. "*"
  46.         end
  47.         term.setCursorPos(20,10)
  48.         term.setTextColor(colors.white)
  49.         print(secret)
  50.        
  51.         local event, button, x, y = os.pullEvent("mouse_click")
  52.         if (y == 7 and x >= 20 and x <= 31) then
  53.             paintutils.drawLine(20, 7, 31, 7, colors.black)
  54.             term.setCursorPos(20,7)
  55.             term.setTextColor(colors.white)
  56.             User = read()
  57.         elseif (y == 10 and x >= 20 and x <= 31) then
  58.             paintutils.drawLine(20, 10, 31, 10, colors.black)
  59.             term.setCursorPos(20,10)
  60.             term.setTextColor(colors.white)
  61.             Password = read("*")
  62.         elseif (y == 12 and x >= 20 and x <= 31) then
  63.             PageNewAccount()
  64.         elseif (y >= 16 and y <= 18 and x >= 22 and x <= 29) then
  65.             PageInvoice()
  66.         end
  67.     end
  68. end
  69.  
  70. function PageNewAccount()
  71.     local Loop = true
  72.     local User = ""
  73.     local Password = ""
  74.     local ConfirmPassword = ""
  75.     while (Loop) do
  76.         --Paint
  77.         term.setBackgroundColor(colors.white)
  78.         term.setTextColor(colors.black)
  79.         term.clear()
  80.        
  81.         term.setCursorPos(23,2)
  82.         print("E-MAIL")
  83.         paintutils.drawFilledBox(19, 5, 32, 14, colors.yellow)
  84.        
  85.         term.setCursorPos(20,6)
  86.         print("User:")
  87.         term.setCursorPos(20,9)
  88.         print("Password:")
  89.         term.setCursorPos(20,12)
  90.         print("Confirm pass:")
  91.        
  92.         paintutils.drawPixel(2,2,colors.red)
  93.         term.setCursorPos(2,2)
  94.         print("< Back")
  95.        
  96.         paintutils.drawLine(20, 7, 31, 7, colors.black)
  97.         paintutils.drawLine(20, 10, 31, 10, colors.black)
  98.         paintutils.drawLine(20, 13, 31, 13, colors.black)
  99.        
  100.         paintutils.drawFilledBox(21, 16, 30, 18, colors.green)
  101.         term.setCursorPos(22,17)
  102.         term.setTextColor(colors.white)
  103.         print("Register")
  104.        
  105.         paintutils.drawPixel(20, 7, colors.black)
  106.         term.setCursorPos(20,7)
  107.         term.setTextColor(colors.white)
  108.         print(User)
  109.        
  110.         local secret = ""
  111.         for i = 1,string.len(Password) do
  112.             secret = secret .. "*"
  113.         end
  114.         term.setCursorPos(20,10)
  115.         term.setTextColor(colors.white)
  116.         print(secret)
  117.        
  118.         secret = ""
  119.         for i = 1,string.len(ConfirmPassword) do
  120.             secret = secret .. "*"
  121.         end
  122.         term.setCursorPos(20,13)
  123.         term.setTextColor(colors.white)
  124.         print(secret)
  125.        
  126.         local event, button, x, y = os.pullEvent("mouse_click")
  127.         if (y == 7 and x >= 20 and x <= 31) then
  128.             paintutils.drawLine(20, 7, 31, 7, colors.black)
  129.             term.setCursorPos(20,7)
  130.             term.setTextColor(colors.white)
  131.             User = read()
  132.         elseif (y == 10 and x >= 20 and x <= 31) then
  133.             paintutils.drawLine(20, 10, 31, 10, colors.black)
  134.             term.setCursorPos(20,10)
  135.             term.setTextColor(colors.white)
  136.             Password = read("*")
  137.         elseif (y == 13 and x >= 20 and x <= 31) then
  138.             paintutils.drawLine(20, 13, 31, 13, colors.black)
  139.             term.setCursorPos(20,13)
  140.             term.setTextColor(colors.white)
  141.             ConfirmPassword = read("*")
  142.         elseif (y == 2 and x >= 2 and x <= 7) then
  143.             Loop = false
  144.         elseif (y >= 16 and y <= 18 and x >= 21 and x <= 31) then
  145.             --register here
  146.             if (true) then
  147.                 Loop = false
  148.             end
  149.         end
  150.     end
  151. end
  152.  
  153. function PageInvoice()
  154.     local Loop = true
  155.     local mailIndex = nil
  156.     while(Loop) do
  157.         --Paint
  158.         term.setBackgroundColor(colors.white)
  159.         term.setTextColor(colors.black)
  160.         term.clear()
  161.        
  162.         paintutils.drawFilledBox(1, 1, 51, 3, colors.yellow)
  163.         paintutils.drawLine(15, 4, 15, 19, colors.black)
  164.        
  165.         for i=4,19,3 do
  166.             if (i%2==0) then
  167.                 paintutils.drawFilledBox(1,i,14,i+2, colors.white)
  168.             else
  169.                 paintutils.drawFilledBox(1,i,14,i+2, colors.pink)
  170.             end
  171.         end
  172.        
  173.         local y = 4
  174.         for i,mail in ipairs(Emails) do
  175.             if (y%2==0) then
  176.                 paintutils.drawPixel(2,y,colors.white)
  177.             else
  178.                 paintutils.drawPixel(2,y,colors.pink)
  179.             end
  180.             term.setCursorPos(2,y)
  181.             print(mail.From)
  182.             term.setCursorPos(2,y+1)
  183.             print(mail.Subject)
  184.             y=y+3
  185.         end
  186.        
  187.         term.setTextColor(colors.white)
  188.         paintutils.drawPixel(44, 2, colors.red)
  189.         term.setCursorPos(44,2)
  190.         print("Log out")
  191.         paintutils.drawPixel(2, 2, colors.green)
  192.         term.setCursorPos(2,2)
  193.         print("New email")
  194.        
  195.         term.setTextColor(colors.black)
  196.         for i,mail in ipairs(Emails) do
  197.             if (i==mailIndex) then
  198.                 paintutils.drawPixel(17, 5, colors.white)
  199.                 term.setCursorPos(17,5)
  200.                 print("From: ")
  201.                 paintutils.drawLine(25, 5, 50, 5, colors.lightBlue)
  202.                 term.setCursorPos(22,5)
  203.                 print(mail.From)
  204.  
  205.                 paintutils.drawPixel(17, 6, colors.white)
  206.                 term.setCursorPos(17,6)
  207.                 print("Subject: ")
  208.                 paintutils.drawLine(25, 6, 50, 6, colors.lightBlue)
  209.                 term.setCursorPos(25,6)
  210.                 print(mail.Subject)
  211.  
  212.                 paintutils.drawPixel(17, 7, colors.white)
  213.                 term.setCursorPos(17,7)
  214.                 print("Content:")
  215.                 paintutils.drawFilledBox(17,8,50,18, colors.lightBlue)
  216.                 local startY = 8
  217.                 local startX = 17
  218.                 for i = 1, #mail.Content do
  219.                     if (startX >= 50) then
  220.                         startX = 17
  221.                         startY = startY + 1
  222.                     end
  223.  
  224.                     local c = mail.Content:sub(i,i)
  225.                     term.setCursorPos(startX,startY)
  226.                     print(c)
  227.                     startX = startX + 1
  228.                 end
  229.             end
  230.         end
  231.        
  232.         local event, button, x, y = os.pullEvent("mouse_click")
  233.         if (y == 2 and x >= 44 and x <= 50) then
  234.             Loop = false
  235.         elseif (y == 2 and x >= 2 and x <= 10) then
  236.             PageNew()
  237.         end
  238.        
  239.         local iy = 4
  240.         for i,mail in ipairs(Emails) do
  241.             if (x >= 1 and x <= 14 and y >= iy and y <= iy+2) then
  242.                 mailIndex = i
  243.             end
  244.             iy=iy+3
  245.         end
  246.     end
  247. end
  248.    
  249. function PageNew()
  250.     local mail = {From=User, Subject="", Content="", To=""}
  251.     local Loop = true
  252.     while (Loop) do
  253.         --Paint
  254.         term.setBackgroundColor(colors.white)
  255.         term.clear()
  256.        
  257.         paintutils.drawFilledBox(1, 1, 51, 3, colors.yellow)
  258.        
  259.         term.setTextColor(colors.white)
  260.         paintutils.drawPixel(44, 2, colors.red)
  261.         term.setCursorPos(44,2)
  262.         print("Cancel")
  263.         paintutils.drawPixel(2, 2, colors.green)
  264.         term.setCursorPos(2,2)
  265.         print("Send")
  266.        
  267.         term.setTextColor(colors.black)
  268.         paintutils.drawPixel(2, 5, colors.white)
  269.         term.setCursorPos(2,5)
  270.         print("Destination: ")
  271.         paintutils.drawLine(14, 5, 50, 5, colors.lightBlue)
  272.         term.setCursorPos(14,5)
  273.         print(mail.To)
  274.  
  275.         paintutils.drawPixel(2, 6, colors.white)
  276.         term.setCursorPos(2,6)
  277.         print("Subject: ")
  278.         paintutils.drawLine(10, 6, 50, 6, colors.lightBlue)
  279.         term.setCursorPos(10,6)
  280.         print(mail.Subject)
  281.  
  282.         paintutils.drawPixel(2, 7, colors.white)
  283.         term.setCursorPos(2,7)
  284.         print("Content:")
  285.         paintutils.drawFilledBox(2,8,50,18, colors.lightBlue)
  286.         term.setCursorPos(2,8)
  287.         print(mail.Content)
  288.        
  289.         local event, button, x, y = os.pullEvent("mouse_click")
  290.         if (y == 2 and x >= 44 and x <= 49) then
  291.             Loop = false
  292.         elseif (y == 2 and x >= 2 and x <= 5) then
  293.             -- Send email
  294.             Loop = false
  295.         elseif (y == 5 and x >= 14 and x <= 50) then
  296.             term.setCursorPos(14,5)
  297.             mail.To = read()
  298.         elseif (y == 6 and x >= 10 and x <= 50) then
  299.             term.setCursorPos(10,6)
  300.             mail.Subject = read()
  301.         elseif (y >= 8 and y <= 18 and x >= 2 and x <= 50) then
  302.             term.setCursorPos(2,8)
  303.             mail.Content = read()
  304.         end
  305.     end
  306. end
  307.  
  308. main()
Advertisement
Add Comment
Please, Sign In to add comment