Advertisement
Mackan90096

MackOS V. 1.1 - Dev. Edition

Mar 30th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.51 KB | None | 0 0
  1. function main()
  2. bar1 = paintutils.loadImage(".bar1")
  3. logo = paintutils.loadImage(".logo")
  4. icon = paintutils.loadImage(".icon")
  5. TriviaLogo = paintutils.loadImage(".trivia")
  6. tBarC = 8
  7. tBartC = 1
  8. backColor = 1
  9. scroll = 0
  10. Version = "1.0"
  11. credCol = 32
  12. firstCol = 1
  13. secCol = 2048
  14. Author  = "Mackan90096"
  15. ErrCol1 = 16384
  16. calcCol = 256
  17.  
  18. --Desktop
  19. term.setBackgroundColor(backColor)
  20. term.clear()
  21.  
  22. slc = 0
  23.  
  24. function passgen()
  25. function clear()
  26.   term.clear()
  27.   term.setCursorPos(1,1)
  28. end
  29. function center(text,y,mode)
  30.   w,h = term.getSize()
  31.   term.setCursorPos((w/2)-(#text/2),y)
  32.   if mode == nil then mode = "print" end
  33.   if mode == "write" then
  34.     write(text)
  35.   else
  36.     print(text)
  37.   end
  38. end
  39. clear()
  40. write "Length (Max 50): "
  41. local length = read()
  42. if tonumber(length) == false then
  43.   print("Use a number please")
  44.   sleep(2)
  45.   error()
  46. else
  47.   length = tonumber(length)
  48. end
  49. if length > 51 then
  50.         print("Please enter a length 50 characters or below")
  51.         sleep(2)
  52.         error()
  53. end
  54. lower = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
  55. upper = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}
  56. special = {'!','@','#','$','%','^','&','*'}
  57. numbers = {'0','1','2','3','4','5','6','7','8','9'}
  58. mode = {"usnl","usln","ulsn","unsl","unls","ulns","nusl", "nsul", "sunl", "snul","lsnu","lsun","luns","lusn","lnsu","lnus" ,"nu", "un", "sn", "ns", "us", "su", "u", "s", "n"}
  59. clear()
  60. center("Modes: Upper[u], special[s], number[n], lower[l]",2)
  61. print()
  62. print()
  63. write "write all modes you want (no commas): "
  64. local l = false
  65. local u = false
  66. local s = false
  67. local n = false
  68. mds = ""
  69. while true do
  70.   event, key = os.pullEvent("key")
  71.   if key == 22 then
  72.     if u == false then
  73.       u = true
  74.       term.setCursorPos(1,7)
  75.       print"Upper"
  76.           mds = mds.."u"
  77.     else
  78.       u = false
  79.       term.setCursorPos(1,7)
  80.       term.clearLine()
  81.           mds = mds:gsub( "u", "" )
  82.     end
  83.   elseif key == 31 then
  84.     if s == false then
  85.       s = true
  86.       term.setCursorPos(1,8)
  87.       print"Special"
  88.           mds = mds.."s"
  89.     else
  90.       s = false
  91.       term.setCursorPos(1,8)
  92.       term.clearLine()
  93.           mds = mds:gsub("s","")
  94.     end
  95.   elseif key == 49 then
  96.     if n == false then
  97.       n = true
  98.       term.setCursorPos(1,9)
  99.       print"Number"
  100.           mds = mds.."n"
  101.     else
  102.       n = false
  103.       term.setCursorPos(1,9)
  104.       term.clearLine()
  105.           mds = mds:gsub("n", "")
  106.     end
  107.   elseif key == 38 then
  108.     if l == false then
  109.       l = true
  110.       term.setCursorPos(1,10)
  111.       print"Lower"
  112.           mds = mds.."l"
  113.     else
  114.       l = false
  115.       term.setCursorPos(1,10)
  116.       term.clearLine()
  117.           mds = mds:gsub("l", "")
  118.     end
  119.   elseif key == 28 and (l or n or s or u) then
  120.     break
  121.   end
  122. end
  123. mds = string.lower(mds)
  124. local test = false
  125. for i=1, #mode do
  126.   if mds == mode[i] then
  127.     test = true
  128.     break
  129.   end
  130. end
  131. if test == false then
  132.   print("Invalid mode: "..mds)
  133. end
  134. modes = {}
  135. message = ""
  136. if l == true and n == true and s == true and u == true then
  137.   for i=1, length do
  138.     num = math.random(4)
  139.     if num == 1 then
  140.       message = message..lower[math.random(#lower)]
  141.     elseif num == 2 then
  142.       message = message..upper[math.random(#upper)]
  143.     elseif num == 3 then
  144.       message = message..special[math.random(#special)]
  145.     elseif num == 4 then
  146.       message = message..numbers[math.random(#numbers)]
  147.     end
  148.   end
  149. elseif n == true and s == true and u == true then
  150.   for i=1, length do
  151.     num = math.random(3)
  152.     if num == 1 then
  153.       message = message..upper[math.random(#upper)]
  154.     elseif num == 2 then
  155.       message = message..special[math.random(#special)]
  156.     elseif num == 3 then
  157.       message = message..numbers[math.random(#numbers)]
  158.     end
  159.   end
  160. elseif n == true and s == true and l == true then
  161.   for i=1, length do
  162.     num = math.random(3)
  163.     if num == 1 then
  164.       message = message..special[math.random(#special)]
  165.     elseif num == 2 then
  166.       message = message..numbers[math.random(#numbers)]
  167.     elseif num == 3 then
  168.       message = message..lower[math.random(#lower)]
  169.     end
  170.   end
  171. else if n == true and s == true then
  172.   for i=1, length do
  173.     num = math.random(2)
  174.     if num == 1 then
  175.       message = message..numbers[math.random(#numbers)]
  176.     elseif num == 2 then
  177.       message = message..special[math.random(#special)]
  178.     end
  179.   end
  180. elseif l == true and u == true and s == true then
  181.   for i=1, length do
  182.     num = math.random(3)
  183.     if num == 1 then
  184.       message = message..upper[math.random(#upper)]
  185.     elseif num == 2 then
  186.       message = message..lower[math.random(#lower)]
  187.     elseif num == 3 then
  188.       message = message..special[math.random(#special)]
  189.     end
  190.   end
  191. elseif s == true and u == true then
  192.   for i=1, length do
  193.     num = math.random(2)
  194.     if num == 1 then
  195.       message = message..special[math.random(#special)]
  196.     else
  197.       message = message..upper[math.random(#upper)]
  198.     end
  199.   end
  200. elseif l == true and n == true and u == true then
  201.   for i=1, length do
  202.     num = math.random(3)
  203.     if num == 1 then
  204.       message = message..upper[math.random(#upper)]
  205.     elseif num == 2 then
  206.       message = message..numbers[math.random(#numbers)]
  207.     elseif num == 3 then
  208.       message = message..lower[math.random(#lower)]
  209.     end
  210.   end
  211. elseif u == true and n == true then
  212.   for i=1, length do
  213.     num = math.random()
  214.     if num == 1 then
  215.       message = message..upper[math.random(#upper)]
  216.     else
  217.       message = message..numbers[math.random(#numbers)]
  218.     end
  219.   end
  220. elseif l == true and n == true then
  221.   for i=1, length do
  222.     num = math.random(2)
  223.     if num == 1 then
  224.       message = message..numbers[math.random(#numbers)]
  225.     elseif num == 2 then
  226.       message = message..lower[math.random(#lower)]
  227.     end
  228.   end
  229. elseif l == true and s == true then
  230.   for i=1, length do
  231.     num = math.random(2)
  232.     if num == 1 then
  233.       message = message..special[math.random(#special)]
  234.     elseif num == 2 then
  235.       message = message..lower[math.random(#lower)]
  236.     end
  237.   end
  238. elseif l == true and u == true then
  239.   for i=1, length do
  240.     num = math.random(2)
  241.     if num == 1 then
  242.       message = message..upper[math.random(#upper)]
  243.     elseif num == 2 then
  244.       message = message..lower[math.random(#lower)]
  245.     end
  246.   end
  247. elseif l == true then
  248.   for i=1, length do
  249.     message = message..lower[math.random(#lower)]
  250.   end
  251. elseif n == true then
  252.   for i=1, length do
  253.     message = message..numbers[math.random(#numbers)]
  254.   end
  255. elseif s == true then
  256.   for i=1, length do
  257.     message = message..special[math.random(#special)]
  258.   end
  259. elseif u == true then
  260.   for i=1, length do
  261.     message = message..upper[math.random(#upper)]
  262.   end
  263. end
  264. end
  265. clear()
  266. center("Your Password is: ", 4)
  267. center(message,6)
  268. sleep(10)
  269. term.clear()
  270. drawDesktop()
  271. end
  272.  
  273. function credits()
  274. term.clear()
  275. term.setCursorPos(1,1)
  276. term.setTextColor(credCol)
  277. print("Credits")
  278. term.setCursorPos(1,3)
  279. print("Programs and apis:")
  280. term.setCursorPos(1,5)
  281. print("CCalendar - TheOriginalBIT")
  282. term.setCursorPos(1,6)
  283. print("Passgen -  Conn332")
  284. term.setCursorPos(1,8)
  285. print("Help in development:")
  286. term.setCursorPos(1,10)
  287. print("All the great people that helped me on the forums! - You know who you are :)")
  288. term.setCursorPos(1,13)
  289. print("Special thanks to:")
  290. term.setCursorPos(1,15)
  291. print("faubiguy - Helping me with the password changing")
  292. term.setCursorPos(1,17)
  293. write("To return type anything and hit enter: ")
  294. local input = read()
  295. if input == "1" then
  296. term.clear()
  297. drawDesktop()
  298. else
  299. term.clear()
  300. drawDesktop()
  301. end
  302. end
  303.  
  304. function login()
  305. term.clear()
  306. term.setCursorPos(1,1)
  307. print("Logging in")
  308. term.setCursorPos(1,3)
  309. write("Username: ")
  310. usrName = read()
  311. write("Password: ")
  312. local pass = read("*")
  313. file = fs.open("users/"..usrName,"r")
  314. if not fs.exists("users/"..usrName) then
  315. term.clear()
  316. term.setCursorPos(1,1)
  317. print("Login failed")
  318. sleep(1)
  319. term.clear()
  320. drawDesktop()
  321. elseif fs.exists("users/"..usrName) then
  322. local fileData = {}
  323. local line = file.readLine()
  324. repeat
  325. table.insert(fileData, line)
  326. line = file.readLine()
  327. until line == nil -- readLine()
  328. file.close()
  329. local passFromFile = fileData[1]
  330. if pass == passFromFile then
  331. term.clear()
  332. term.setCursorPos(1,1)
  333. print("Login succeded!")
  334. sleep(1)
  335. term.clear()
  336. drawDesktop2()
  337. else
  338. term.clear()
  339. term.setCursorPos(1,1)
  340. print("Login failed!")
  341. sleep(1)
  342. term.clear()
  343. drawDesktop()
  344. end
  345. end
  346. end
  347.  
  348. function register()
  349. term.clear()
  350. term.setCursorPos(1,1)
  351. print("Registering")
  352. term.setCursorPos(1,3)
  353. write("Username: ")
  354. local usrName = read()
  355. term.setCursorPos(1,4)
  356. write("Password: ")
  357. local pass = read("*")
  358. fs.makeDir("users")
  359. if not fs.exists("users/"..usrName) then
  360. local file = fs.open("users/"..usrName, "a")
  361. file.writeLine(pass)
  362. file.close()
  363. sleep(0.5)
  364. term.clear()
  365. term.setCursorPos(1,1)
  366. print("Registered!")
  367. sleep(0.5)
  368. term.clear()
  369. drawDesktop()
  370. elseif fs.exists("users/"..usrName) then
  371. term.clear()
  372. term.setCursorPos(1,1)
  373. print("Username already in use!")
  374. sleep(1)
  375. term.clear()
  376. drawDesktop()
  377. end
  378. end
  379.  
  380. function titleBar2()
  381.   term.setCursorPos(1,1)
  382.   term.setBackgroundColor(tBarC)
  383.   term.setTextColor(tBartC)
  384.   term.clearLine()
  385.   term.setCursorPos(3,1)
  386.   print("[Begin]")
  387.   term.setCursorPos(12,1)
  388.   print("[Games]")
  389.   term.setCursorPos(20,1)
  390.   print("Logged in as: "..usrName)
  391.  
  392. end
  393.  
  394. function drawDesktop2()
  395.   slc = 2
  396.   term.setBackgroundColor(backColor)
  397.   term.clear()
  398.   term.setTextColor(32)
  399.   term.setCursorPos(1,20)
  400.   print("Running Version: "..Version)
  401.   paintutils.drawImage(logo,1,1)
  402.   paintutils.drawImage(icon,3,10)
  403.   titleBar2()
  404. end
  405.  
  406. function drawMenu2()
  407. term.setTextColor(256)
  408. term.setBackgroundColor(128)
  409. term.setCursorPos(1,2)
  410. print("          ")
  411. term.setCursorPos(1,3)
  412. print("Logout    ")
  413. term.setCursorPos(1,4)
  414. print("Calculator")
  415. term.setCursorPos(1,5)
  416. print("Account   ")
  417. term.setCursorPos(1,6)
  418. print("Calendar  ")
  419. term.setCursorPos(1,7)
  420. print("Email     ")
  421. term.setCursorPos(1,8)
  422. print("Shutdown  ")
  423. term.setCursorPos(1,9)
  424. print("Reboot    ")
  425. term.setCursorPos(1,10)
  426. print("          ")
  427. end
  428.  
  429. function drawMenu3()
  430. term.setTextColor(256)
  431. term.setBackgroundColor(128)
  432. term.setCursorPos(12,2)
  433. print("          ")
  434. term.setCursorPos(12,3)
  435. print(" Trivia   ")
  436. term.setCursorPos(12,4)
  437. print("          ")
  438. end
  439.  
  440. function titleBar()
  441.   term.setCursorPos(1,1)
  442.   term.setBackgroundColor(tBarC)
  443.   term.setTextColor(tBartC)
  444.   term.clearLine()
  445.   term.setCursorPos(3,1)
  446.   print("[Begin]")
  447. end
  448.  
  449. function drawDesktop()
  450.   term.setBackgroundColor(backColor)
  451.   term.clear()
  452.   term.setCursorPos(1,20)
  453.   term.setTextColor(32)
  454.   print("Running Version: "..Version)
  455.   paintutils.drawImage(logo,1,1)
  456.   titleBar()
  457. end
  458.  
  459. function drawMenu1()
  460. term.setTextColor(256)
  461. term.setBackgroundColor(128)
  462. term.setCursorPos(1,2)
  463. print("          ")
  464. term.setCursorPos(1,3)
  465. print(" Login    ")
  466. term.setCursorPos(1,4)
  467. print(" Register ")
  468. term.setCursorPos(1,5)
  469. print(" Reboot   ")
  470. term.setCursorPos(1,6)
  471. print(" Shutdown ")
  472. term.setCursorPos(1,7)
  473. print(" Passgen  ")
  474. term.setCursorPos(1,8)
  475. print(" Credits  ")
  476. term.setCursorPos(1,9)
  477. print("          ")
  478. end
  479.  
  480. function calc()
  481. term.setTextColor(calcCol)
  482. term.clear()
  483. term.setCursorPos(1,1)
  484. print("Do you want to Add, Subtract, Divide, Multiply or use ^?")
  485. op = read()
  486. print("")
  487. print("What is the first number to be operated on?")
  488. num1 = tonumber(read())
  489. print("")
  490. print("And the second number?")
  491. num2 = tonumber(read())
  492. print("")
  493. if op == "add" then
  494. result = num1+num2
  495. print(result)
  496. sleep(5)
  497. term.clear()
  498. drawDesktop2()
  499. elseif op == "multiply" then
  500. result = num1*num2
  501. print(result)
  502. sleep(5)
  503. term.clear()
  504. drawDesktop2()
  505. elseif op == "subtract" then
  506. result = num1-num2
  507. print(result)
  508. sleep(5)
  509. term.clear()
  510. drawDesktop2()
  511. elseif op == "divide" then
  512. result = num1/num2
  513. print(result)
  514. sleep(5)
  515. term.clear()
  516. drawDesktop2()
  517. elseif op == "^" then
  518. result = num1^num2
  519. print(result)
  520. sleep(5)
  521. term.clear()
  522. drawDesktop2()
  523. else
  524. term.clear()
  525. term.setCursorPos(1,1)
  526. print("You failed! Try again.")
  527. sleep(1)
  528. term.clear()
  529. drawDesktop2()
  530. end
  531. end
  532.  
  533. function titlebar3()
  534. term.setCursorPos(1,1)
  535.   term.setBackgroundColor(tBarC)
  536.   term.setTextColor(tBartC)
  537.   term.clearLine()
  538.   term.setCursorPos(3,1)
  539.   print("[Begin] ")
  540.   term.setCursorPos(13,1)
  541.   print("Logged in as: "..usrName)
  542. end
  543.  
  544. function acc()
  545. slc = 4
  546. term.setBackgroundColor(backColor)
  547.   term.clear()
  548. paintutils.drawImage(logo,1,1)
  549.   titlebar3()
  550. end
  551.  
  552. function delacc()
  553. slc = 6
  554. term.clear()
  555. term.setCursorPos(1,1)
  556. print("Really delete account?")
  557. term.setCursorPos(1,3)
  558. print("Yes")
  559. term.setCursorPos(7,3)
  560. print("No")
  561. end
  562.  
  563. function delacc2()
  564. term.clear()
  565. term.setCursorPos(1,1)
  566. print("Deleting account")
  567. term.setCursorPos(1,3)
  568. write("Username: ")
  569. usrName = read()
  570. write("Password: ")
  571. local pass = read("*")
  572. file = fs.open("users/"..usrName,"r")
  573. if not fs.exists("users/"..usrName) then
  574. term.clear()
  575. term.setCursorPos(1,1)
  576. print("Failure")
  577. sleep(1)
  578. term.clear()
  579. acc()
  580. elseif fs.exists("users/"..usrName) then
  581. local fileData = {}
  582. local line = file.readLine()
  583. repeat
  584. table.insert(fileData, line)
  585. line = file.readLine()
  586. until line == nil -- readLine()
  587. file.close()
  588. local passFromFile = fileData[1]
  589. if pass == passFromFile then
  590. fs.delete("users/"..usrName)
  591. term.clear()
  592. term.setCursorPos(1,1)
  593. print("Deleted account!")
  594. sleep(1)
  595. term.clear()
  596. drawDesktop()
  597. end
  598. end
  599. end
  600.  
  601. function drawMenu4()
  602. term.setTextColor(256)
  603. term.setBackgroundColor(128)
  604. term.setCursorPos(1,2)
  605. print("           ")
  606. term.setCursorPos(1,3)
  607. print("Change pass")
  608. term.setCursorPos(1,4)
  609. print("Delete acc ")
  610. term.setCursorPos(1,5)
  611. print("Go back    ")
  612. term.setCursorPos(1,6)
  613. print("           ")
  614. end
  615.  
  616. function changepass()
  617. term.clear()
  618. term.setCursorPos(1,1)
  619. write("Username: ")
  620. local usrname = read()
  621. write("Old password: ")
  622. local oldpass = read("*")
  623. write("New password: ")
  624. local newpass = read("*")
  625.  
  626. if not fs.exists("users/"..usrname) then
  627. term.clear()
  628. term.setCursorPos(1,1)
  629. print("No such username!")
  630. sleep(1)
  631. term.clear()
  632. acc()
  633. elseif fs.exists("users/"..usrname) then
  634. local fileData = {}
  635. repeat
  636. local file = fs.open("users/"..usrName,"r")
  637. local line = file.readLine()
  638. while line do
  639.         table.insert(fileData, line)
  640.         line = file.readLine()
  641. end
  642. until line == nil -- readLine()
  643. file.close()
  644. local oldpassFromFile = fileData[1]
  645. if oldpass == oldpassFromFile then
  646. file = fs.open('users/'..usrName,'w') -- Changed from file.clear()
  647. file.writeLine(newpass)
  648. file.close()
  649. term.clear()
  650. term.setCursorPos(1,1)
  651. print("Changed!")
  652. sleep(1)
  653. term.clear()
  654. acc()
  655. else
  656. term.clear()
  657. term.setCursorPos(1,1)
  658. print("Failure!")
  659. sleep(1)
  660. term.clear()
  661. acc()
  662.  
  663. end
  664. end
  665. end
  666.  
  667. --[[
  668. Author: TheOriginalBIT
  669. Version: CUSTOM FOR Mackos
  670. Created: 13 Mar 2013
  671.  
  672. License:
  673.  
  674. COPYRIGHT NOTICE
  675. Copyright © 2013 Joshua Asbury a.k.a TheOriginalBIT [theoriginalbit@gmail.com]
  676.  
  677. Permission is hereby granted only to Mackan90096 to distribute this software as a part of Mackos. If you wish to use this program please contact TheOriginalBIT on the ComputerCraft forums
  678. ]]--
  679.  
  680. function calendar(shorthand, ampm, refreshRate)
  681.   if not os.day then
  682.     print("Sorry but you don't seem to be running the version of ComputerCraft that this program requires (1.48+)")
  683.     return
  684.   end
  685.  
  686.   local useShorthand = (shorthand == true) or false
  687.   local useAmPm = (ampm == true) or false
  688.   local refreshRate = (type(refreshRate) == "number") and refreshRate or 0.05
  689.  
  690.   -- initialise variables
  691.   local currentYear = 1
  692.   local currentMonth = 1
  693.   local currentDay = 1
  694.   local isLeapYear = (currentYear % 4 == 0 and (currentYear % 100 > 0 or  currentYear % 400 == 0))
  695.   local yearPrefix = "AS (After Spawn)"
  696.  
  697.   local monthsTable = {
  698.     {month="January", days=31, shorthand="JAN"},
  699.     {month="February", days=28, shorthand="FEB"},
  700.     {month="March", days=31, shorthand="MAR"},
  701.     {month="April", days=30, shorthand="APR"},
  702.     {month="May", days=31, shorthand="MAY"},
  703.     {month="June", days=30, shorthand="JUNE"},
  704.     {month="July", days=31, shorthand="JULY"},
  705.     {month="August", days=31, shorthand="AUG"},
  706.     {month="September", days=30, shorthand="SEPT"},
  707.     {month="October", days=31, shorthand="OCT"},
  708.     {month="November", days=30, shorthand="NOV"},
  709.     {month="December", days=31, shorthand="DEC"},
  710.   }
  711.  
  712.   local daysTable = {
  713.     {day="Monday", shorthand="MON"},
  714.     {day="Tuesday", shorthand="TUE"},
  715.     {day="Wednesday", shorthand="WED"},
  716.     {day="Thursday", shorthand="THU"},
  717.     {day="Friday", shorthand="FRI"},
  718.     {day="Saturday", shorthand="SAT"},
  719.     {day="Sunday", shorthand="SUN"},
  720.   }
  721.  
  722.   local function updateLeapYear(year)
  723.     isLeapYear = (currentYear % 4 == 0 and (currentYear % 100 > 0 or  currentYear % 400 == 0))
  724.   end
  725.  
  726.   local function updateYear(days)
  727.     currentYear = math.floor(days/(isLeapYear and 366 or 365)+1)
  728.     updateLeapYear(year)
  729.   end
  730.  
  731.   local function updateMonth(days)
  732.     local shiftedDays = days%366
  733.     local d = 0
  734.     for i = 1, #monthsTable do
  735.       local before = d
  736.       if i == 2 and isLeapYear then
  737.         d = d + 29
  738.       else
  739.         d = d + monthsTable[i].days
  740.       end
  741.       if shiftedDays >= before and shiftedDays <= d then
  742.         currentMonth = i
  743.         return
  744.       end
  745.     end
  746.   end
  747.  
  748.   local function updateDay(days)
  749.     local shiftedDays = days%366
  750.     for i = 1, currentMonth - 1 do
  751.       shiftedDays = shiftedDays - monthsTable[i].days
  752.     end
  753.     currentDay = shiftedDays
  754.   end
  755.  
  756.   local function hexToCol(hex)
  757.     local num = tonumber(hex, 16)
  758.     return num ~= nil and 2^num or nil
  759.   end
  760.  
  761.   local function cwrite(msg, y, offset)
  762.     local sw,sh=term.getSize()
  763.     term.setCursorPos(sw/2-#msg/2+(#msg%2 and 0 or 1), (y or (sh/2)) + (offset or 0))
  764.     write(msg)
  765.   end
  766.  
  767.   while true do
  768.     term.clear()
  769.     local dayCount = os.day()
  770.     updateYear(dayCount)
  771.     updateMonth(dayCount)
  772.     updateDay(dayCount)
  773.     cwrite("The time is: "..textutils.formatTime(os.time(), not useAmPm),nil,-2)
  774.     cwrite("The date is: "..currentDay.." "..(useShorthand and monthsTable[currentMonth].shorthand or monthsTable[currentMonth].month).." "..string.format("%.4d",currentYear),nil,2)
  775.  
  776.     os.startTimer(refreshRate)
  777.     os.pullEvent("timer")
  778.   end
  779.   drawDesktop2()
  780. end
  781.  
  782. function email()
  783. term.clear()
  784. write("Name: ")
  785. name = read()
  786. write("Message: ")
  787. msg = read()
  788. email = name.."\n"..msg
  789.  
  790. http.post(
  791.  "http://mackos.netai.net/scripts/email.php?message="..textutils.urlEncode(tostring(email))
  792.  
  793. )
  794. sleep(1)
  795. if http_success then
  796. term.clear()
  797. term.setCursorPos(1,1)
  798. print("Email sent!")
  799. sleep(1)
  800. term.clear()
  801. drawDesktop2()
  802. elseif http_failure then
  803. term.clear()
  804. term.setCursorPos(1,1)
  805. print("Failure!")
  806. sleep(1)
  807. term.clear()
  808. drawDesktop2()
  809. end
  810. end
  811. drawDesktop()
  812.  
  813. function titleBar4()
  814. term.setCursorPos(1,1)
  815.   term.setBackgroundColor(tBarC)
  816.   term.setTextColor(tBartC)
  817.   term.clearLine()
  818.   term.setCursorPos(3,1)
  819.   print("[Trivias]")
  820.   term.setCursorPos(13,1)
  821.   print("Logged in as: "..usrName)
  822. end
  823.  
  824. function trivia()
  825.   slc = 2
  826.   term.setBackgroundColor(backColor)
  827.   term.clear()
  828.   term.setTextColor(32)
  829.   term.setCursorPos(1,20)
  830.   paintutils.drawImage(TriviaLogo,1,1)
  831.   titleBar4()
  832. sleep(5)
  833. slc = 2
  834. drawDesktop2()
  835. end
  836.  
  837. while true do
  838. local event, button, X, Y = os.pullEvent("mouse_click")
  839.  if slc == 0 then
  840.   if event == "mouse_click" then
  841.    if X >= 2 and X <= 8 and Y == 1 and button == 1 then
  842.     drawMenu1()
  843.     slc = 1  
  844.    end
  845.   end
  846.  elseif slc == 1 then
  847.   if X >= 1 and X <= 11 and Y == 3 and button == 1 then slc = 0
  848.     login()
  849.    elseif X >= 1 and X <= 11 and Y == 4 and button == 1 then slc = 0
  850.    register()
  851.    elseif X >= 1 and X <= 11 and Y == 5 and button == 1 then slc = 0        
  852.    os.reboot()
  853.    elseif X >= 1 and X <= 11 and Y == 6 and button == 1 then slc = 0
  854.    os.shutdown()
  855.    elseif X >= 1 and X <= 11 and Y == 7 and button == 1 then slc = 0
  856.    passgen()
  857.    elseif X >= 1 and X <= 11 and Y == 8 and button == 1 then slc = 0
  858.    credits()
  859.    else slc = 0
  860.    drawDesktop()
  861.   end
  862.  
  863.  
  864.   elseif slc == 2 then
  865.    if X >= 1 and X <= 11  and Y == 1 and button == 1 then slc = 3
  866.   drawMenu2()
  867.   elseif X >= 2 and X <= 5 and Y >= 10 and Y <= 16 and button == 1 then
  868.      shell.run("file")
  869.   elseif X >= 12 and X <= 20 and Y == 1 and button == 1 then slc = 7
  870.    drawMenu3()
  871.    else slc = 2
  872.   drawDesktop2()
  873.   end
  874.  
  875.   elseif slc == 3 then
  876.   if X >= 1 and X <= 11 and Y == 3 and button == 1 then
  877.   term.clear()
  878.   slc = 1
  879.   drawDesktop()
  880.   elseif X >= 1 and X <= 11 and Y == 4 and button == 1 then
  881.   calc()
  882.   elseif X >= 1 and X <= 11 and Y == 5 and button == 1 then
  883.   acc()
  884.   elseif X >= 1 and X <= 11 and Y == 6 and button == 1 then
  885.   calendar(true,false,0.05)
  886.   elseif X >= 1 and X <= 11 and Y == 7 and button == 1 then
  887.   email()
  888.   elseif X >= 1 and X <= 11 and Y == 8 and button == 1 then
  889.   os.shutdown()
  890.   elseif X >= 1 and X <= 11 and Y == 9 and button == 1 then
  891.   os.reboot()
  892.   else slc = 2
  893.   drawDesktop2()
  894.  end
  895.  
  896.   elseif slc == 4 then
  897.    if X >= 1 and X <= 11 and Y == 1 and button == 1 then slc = 5
  898.    drawMenu4()
  899.    else slc = 4
  900.    acc()
  901.    end
  902.    elseif slc == 5 then
  903.     if X >= 1 and X <= 11 and Y == 3 and button == 1 then
  904.     changepass()
  905.     elseif X >= 1 and X <= 11 and Y == 4 and button == 1 then
  906.     delacc()
  907.     elseif X >= 1 and X <= 11 and Y == 5 and button == 1 then slc = 2
  908.     drawDesktop2()
  909.     else slc = 4
  910.     acc()
  911.     end
  912.    
  913.     elseif slc == 6 then
  914.     if X >= 1 and X <= 3 and Y == 3 and button == 1 then
  915.     delacc2()
  916.      elseif X >= 7 and X <= 9 and Y == 3 and button == 1 then slc = 4
  917.      acc()
  918.  end
  919.     elseif slc == 7 then
  920.      if X >= 12 and X <= 22 and Y == 3 and button == 1 then slc = 8
  921.      trivia()
  922.      else
  923.      slc = 2
  924.      drawDesktop2()
  925.  end
  926.  end
  927. end
  928.  
  929. end
  930.  
  931. local ok, err = pcall(main)
  932. local w,h = term.getSize()
  933. local Version = "1.0"
  934. if not ok then
  935. term.setBackgroundColor(colors.blue)
  936. term.clear()
  937. term.setTextColor(1)
  938. term.setCursorPos(math.floor(w-string.len("Error!"))/2, 2)
  939. print("Error!")
  940. term.setCursorPos(math.floor(w-string.len(err))/2, 4)
  941. print(err)
  942. term.setCursorPos(math.floor(w-string.len("Please report this to Mackan90096"))/2, 6)
  943. print("Please report this to Mackan90096")
  944. term.setCursorPos(math.floor(w-string.len("You will soon be returned to the start screen."))/2, 8)
  945. print("You will soon be returned to the start screen.")
  946. term.setCursorPos(math.floor(w-string.len("Version: "..Version))/2, 10)
  947. print("Version: "..Version)
  948. sleep(15)
  949. os.reboot()
  950. end
  951. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement