Advertisement
Mackan90096

MackOS [Help Needed Version]

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