Awesomesause200

Ariana v.1

May 7th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.83 KB | None | 0 0
  1. --[[
  2.   This os named Ariana v.1 is made
  3.   by Awesomesause200 you are allowed to edit this
  4.   code but you cannot
  5.   redistribute without my prior allowance
  6. ]]--
  7. --for printing functions
  8. w,h = term.getSize()
  9. --version
  10. osName = "Ariana v.1"
  11. --Username and passwords
  12. Usernames = {"Someone","guest"}
  13. Passwords = {"Someone","guest"}
  14. --Access to Computer
  15. Access = false
  16. --Colors for stuff
  17. BGC = colors.black
  18. TC = colors.white
  19. TC2 = colors.blue
  20. TC3 = colors.lightGray
  21. BarColor = colors.blue
  22. ContextMenuColor1 = colors.lightBlue
  23. ContextMenuTextColor1 = colors.black
  24. --printing functions
  25. --Some learned from nitrofingers
  26. function printCentered(str,ypos)
  27.   term.setCursorPos(w/2 - #str/2,ypos)
  28.   term.write(str)
  29. end
  30.  
  31. function printRight(str,ypos)
  32.   term.setCursorPos(w-#str,ypos)
  33.   term.write(str)
  34. end
  35.  
  36. function pr(str,x,y)
  37.   term.setCursorPos(x,y)
  38.   term.write(str)
  39. end
  40. --Extra functions
  41. function Reset(x,y)
  42.   term.clear()
  43.   term.setCursorPos(x,y)
  44. end
  45.  
  46. function setColor(Backgroundcolor,Textcolor)
  47.   term.setBackgroundColor(Backgroundcolor)
  48.   term.setTextColor(Textcolor)
  49. end
  50.  
  51. function drawHeaderForLogin()
  52.   setColor(BGC,TC)
  53.   term.clear()
  54.   paintutils.drawLine(1,1,w,1,BarColor)
  55.   printCentered("- welcome to "..osName.."-",1)
  56. end
  57.  
  58. function LoginScreen()
  59.   setColor(BGC,TC2)
  60.   printCentered("Username: ",h/2-1)
  61.   printCentered("Password: ",h/2+1)
  62.   printRight("Guest account:",h-2)
  63.   printRight("User = guest ",h-1)
  64.   printRight("Pass = guest ",h)
  65.   term.setCursorPos(w/2 + 4,h/2-1)
  66.   User = read()
  67.   term.setCursorPos(w/2 + 4,h/2+1)
  68.   Pass = read()
  69.   for i = 1,#Usernames do
  70.       if Usernames[i] == User then
  71.           if Passwords[i] == Pass then
  72.               Access = true
  73.           end
  74.       end
  75.   end
  76. end
  77.  
  78. function contextMenu()
  79.   setColor(ContextMenuColor1,ContextMenuTextColor1)
  80.     term.setCursorPos(1,2)
  81.       print("Shutdown       ")
  82.       print("               ")
  83.       print("Restart        ")
  84.       print("               ")
  85.       print("Logoff         ")
  86.  
  87.     e,m,x,y = os.pullEvent("mouse_click")
  88.    
  89.       if m == 1 and x > 1 and x < 16 and y == 2 then
  90.         os.shutdown()
  91.       elseif m == 1 and x > 1 and x < 16 and y == 4 then
  92.         os.reboot()
  93.       elseif m == 1 and x > 1 and x < 16 and y == 6 then
  94.         shell.run(shell.getRunningProgram())
  95.       else
  96.         term.clear()
  97.         mainScreen()
  98.       end
  99. end
  100.  
  101. function drawHeaderForMain()
  102.   setColor(BGC,TC3)
  103.   Reset(1,1)
  104.   paintutils.drawLine(1,1,w,1,BarColor)
  105.   printCentered("-"..osName.."-",1)
  106.   pr("-os-",1,1)
  107. end
  108.  
  109. function mainScreen()
  110.   drawHeaderForMain()
  111.   parallel.waitForAny(
  112.   function()
  113.     while true do
  114.       term.setCursorPos(w-8,1)
  115.         print(textutils.formatTime(os.time()))
  116.       sleep(1)
  117.       term.setCursorPos(w-8,1)
  118.         print("        ")
  119.     end
  120.   end,
  121.   function()
  122.     e,m,x,y = os.pullEvent("mouse_click")
  123.   end
  124.   )
  125.       if m == 1 and x > 1 and x < 5 and y == 1 then
  126.         contextMenu()
  127.       elseif m == 2 then
  128.         term.setCursorPos(x,y)
  129.           print("Edit ariana v.1")
  130.         y = y+1
  131.         term.setCursorPos(x,y)
  132.           print("               ")
  133.         y = y+1
  134.         term.setCursorPos(x,y)
  135.           print("Explore files  ")
  136.         y = y-2
  137.       else
  138.         mainScreen()
  139.       end
  140.      
  141.         newe,newm,newx,newy = os.pullEvent("mouse_click")
  142.        
  143.       if newm == 1 and newx >= x and newx <= x+16 and newy == y then
  144.         shell.run("edit "..shell.getRunningProgram())
  145.         shell.run(shell.getRunningProgram())
  146.       elseif newm == 1 and newx >= x and newx <= x+16 and newy == y+2 then
  147.         shell.run("Browser")
  148.         term.clear()
  149.         mainScreen()
  150.       else
  151.         term.clear()
  152.         mainScreen()
  153.       end
  154. end
  155.  
  156. --Code starts here
  157. drawHeaderForLogin()
  158. LoginScreen()
  159.  
  160. if Access == true then
  161.   mainScreen()
  162. end
Advertisement
Add Comment
Please, Sign In to add comment