Awesomesause200

Ariana v.2

May 20th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.70 KB | None | 0 0
  1. --[[ Version 2 of ariana is not to be edited by
  2. anyone other then Awesomesause200 but your more
  3. then welcome to look at it]]--
  4.  
  5. --Get screen size
  6. local w,h = term.getSize()
  7. --Users and Passes
  8. local Usernames = {"guest","name","Admin"}
  9. local Passwords = {"guest","name","Admin"}
  10. --Versions
  11. local Version = "Ariana v.2.1"
  12. --Possible sides for modems
  13. local sides = {"top","bottom","left","right","back","front"}
  14. --Access state
  15. local Access = false
  16. --Colors
  17. local BarColor = colors.purple
  18. local TextColor = colors.white
  19. local BGReg = colors.black
  20. --Programs list
  21. local IM = ".os/Block_talk"
  22. local Browser = ".os/Browser"
  23. local This = shell.getRunningProgram()
  24. --Icons list
  25. local IMIcon = ".os/IMIcon"
  26. local BrowserIcon = ".os/FileExplore"
  27. --Options on menu
  28. local Options = {"Shutdown","Restart"}
  29. local OptiMax = 9
  30. local OptiMin = 1
  31. --Paint function
  32. local function setColor(col1,col2)
  33.   term.setBackgroundColor(col1)
  34.   term.setTextColor(col2)
  35. end
  36. --Print functions
  37. local function Reset(x,y)
  38.   term.clear()
  39.   term.setCursorPos(x,y)
  40. end
  41.  
  42. local function printCentered(str,ypos)
  43.   term.setCursorPos(w/2-#str/2,ypos)
  44.   term.write(str)
  45. end
  46.  
  47. local function printPos(str,x,y)
  48.   term.setCursorPos(x,y)
  49.   term.write(str)
  50. end
  51. --Login header
  52. local function login()
  53.     term.setBackgroundColor(BGReg)
  54.     paintutils.drawLine(1,1,w,1,BarColor)
  55.     paintutils.drawLine(1,h,w,h,BarColor)
  56.     printCentered("Welcome to "..Version.."-",1)
  57.     term.setBackgroundColor(BGReg)
  58.     printCentered("Sign in as guest",h/2-1)
  59.     printCentered("Sign in as user ",h/2+1)
  60.    
  61.     local e,m,x,y = os.pullEvent("mouse_click")
  62.    
  63.     if m == 1 and x > 16 and x < 32 and y == 8 then
  64.         Access = true
  65.     elseif m == 1 and x > 16 and x < 32 and y == 10 then
  66.         term.clear()
  67.         paintutils.drawLine(1,1,w,1,BarColor)
  68.         paintutils.drawLine(1,h,w,h,BarColor)
  69.         printCentered("Welcome to "..Version.."-",1)
  70.        
  71.         printCentered("Username: ",h/2)
  72.         local User = read()
  73.        
  74.             if User == "User" then
  75.                 Access = true
  76.             else
  77.                 Access = false
  78.             end
  79.     else
  80.         shell.run(This)
  81.     end
  82. end
  83.  
  84. --Menu decrotive
  85. local function menuFX()
  86.   local xFX,yFX = 1,h-1
  87.  
  88.   for i = 1,#Options do
  89.     for j = 1,#Options[i] do
  90.       term.setCursorPos(xFX-#Options[i]+1,yFX)
  91.       term.write(Options[i])
  92.       xFX = xFX + 1
  93.       sleep(0.05)
  94.     end
  95.     yFX = yFX - 1
  96.     xFX = 1
  97.   end
  98. end
  99.  
  100. --Main screen after login
  101. local function mainScreen()
  102.   term.clear()
  103.   paintutils.drawLine(1,1,w,1,BarColor)
  104.   term.setTextColor(TextColor)
  105.   term.setBackgroundColor(BGReg)
  106.   paintutils.drawLine(1,h,w,h,BarColor)
  107.   printCentered("-Welcome to "..Version.."-",1)
  108.   printPos("-Menu-",1,h)
  109.   paintutils.drawImage(paintutils.loadImage(BrowserIcon),3,3)
  110.   paintutils.drawImage(paintutils.loadImage(IMIcon),14,3)
  111.      
  112.   local e,m,x,y = os.pullEvent("mouse_click")
  113.  
  114.   if m == 1 and x > 3 and x < 10 and y > 3 and y < 10 then
  115.     term.setBackgroundColor(BGReg)
  116.     shell.run(Browser)
  117.     term.clear()
  118.     mainScreen()
  119.   elseif m == 1 and x > 14 and x < 21 and y > 3 and y < 10 then
  120.     term.setBackgroundColor(BGReg)
  121.     shell.run(IM)
  122.     term.clear()
  123.     mainScreen()   
  124.   elseif m == 1 and x > 1 and x < 6 and y == h then
  125.     term.setBackgroundColor(BGReg)
  126.     menuFX()
  127.      
  128.   local e,m,x,y = os.pullEvent("mouse_click")
  129.  
  130.   if m == 1 and x > OptiMin and x < OptiMax and y == h-1 then
  131.     os.shutdown()
  132.   elseif m == 1 and x > OptiMin and x < OptiMax and y == h-2 then
  133.     os.reboot()
  134.   else
  135.     term.clear()
  136.     mainScreen()
  137.   end
  138.  
  139.   else
  140.     term.setBackgroundColor(BGReg)
  141.     term.clear()
  142.     mainScreen()
  143.   end
  144. end
  145.  
  146. Reset(1,1)
  147. login()
  148.  
  149. if Access == true then
  150.   term.setBackgroundColor(BGReg)
  151.   Reset(1,1)
  152.   term.setBackgroundColor(BGReg)
  153.   mainScreen()
  154. end
Advertisement
Add Comment
Please, Sign In to add comment