Guest User

login

a guest
Jan 26th, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.98 KB | None | 0 0
  1. local desktopBackground(colors.white)
  2. --Change this since you dont want you background
  3. -- to have a weird outline.  Options are
  4. --colors.white, colors.green, colors.blue
  5. --colors.lightBlue, colors.red, colors.lightGrey,
  6. --colors.grey, colors.yellow, colors.pink,
  7. --colors.lime, colors.orange, colors.magenta,
  8. --colors.cyan, colors.purple, & colors.brown
  9.  
  10.  
  11. --os.pullEvent = os.pullEventRaw
  12.  
  13. function deskReset()
  14. term.setBackgroundColor(colors.white)
  15. term.clear()
  16. end
  17. function loginButton()
  18.  term.setCursorPos(1.5,1)
  19.  print("[Login]")
  20. end
  21. function titleBar()
  22.  term.setCursorPos(1,1)
  23.  term.setBackgroundColor(8)
  24.  term.setTextColor(colors.white)
  25.  term.clearLine()
  26.  term.setCursorPos(40,1)
  27.  print("Rock OS V. 1")
  28. end
  29.  
  30. function file()
  31. local FileList = fs.list("")
  32. term.setBackgroundColor(2048)
  33. term.clear()
  34. titleBarPost()
  35. term.setCursorPos(1,2)
  36. term.setTextColor(colors.white)
  37. local counter = 0
  38. for _, file in ipairs(FileList) do
  39.  if counter % 2 == 0 then
  40.   term.setBackgroundColor(colors.gray)
  41.  else
  42.   term.setBackgroundColor(colors.lightGray)
  43.  end
  44.  term.clearLine()
  45.  print(file)
  46.  counter = counter + 1
  47. end
  48. end
  49.  
  50. function titleBarLogin()
  51.  titleBar()
  52.  loginButton()
  53. end
  54.  
  55. function titleBarPost()
  56.  titleBar()
  57.  term.setCursorPos(2, 1)
  58.  print("Hello, "..user)
  59. end
  60.  
  61. function drawPreDesktop()
  62. deskReset()
  63. bground = paintutils.loadImage(".background")
  64. paintutils.drawImage(bground, 1, 1)
  65. titleBarLogin()
  66. loginWait()
  67. end
  68. function drawLoginDesktop()
  69.  deskReset()
  70.  bground = paintutils.loadImage(".background")
  71.  paintutils.drawImage(bground, 1, 1)
  72.  titleBar()
  73. end
  74.  
  75. function drawDesktop()
  76.  deskReset()
  77.  bground = paintutils.loadImage(".background")
  78.  paintutils.drawImage(bground, 1, 1)
  79.  titleBarPost()
  80.  icon = paintutils.loadImage(".icon")
  81.  paintutils.drawImage(icon, 1, 1)
  82. end
  83.  
  84. function loginWait()
  85. while true do
  86.  local event, button, X, Y = os.pullEvent()
  87.   if slc == 0 then
  88.    if event == "mouse_click" then
  89.     if X >=0.5 and X <= 7.5 and Y == 1 and button == 1 then
  90.      login()
  91.      
  92.      else
  93.      drawPreDesktop()
  94.     end
  95.    end
  96.   end
  97. end
  98. end
  99.  
  100. function deskWait()
  101. local event, button, X, Y = os.pullEvent()
  102. if event == "mouse_click" then
  103.  if button == 1 then
  104.   if X >= 2 and X <= 5 and  Y >= 3 and Y <= 7 then
  105.    file()
  106.   end
  107.  end
  108. end
  109. end
  110.  
  111. function login()
  112. drawLoginDesktop()
  113. term.setCursorPos(1,2)
  114. term.setBackgroundColor(colors.white)
  115. term.setTextColor(colors.black)
  116.  
  117. username = {"this slot", "Zaydok", "test"}  
  118. password = {"never works", "bobjeffjeff", "test"}  
  119. i = # username
  120.  
  121. write("Username: ")
  122. user = read()
  123.  
  124. write("Password: ")
  125. pass = read()
  126.  
  127. for i = 0, i do
  128.  if user == username[i] and pass == password[i] then
  129.    access = true
  130.   else
  131.    access = false
  132.  end
  133. end
  134.  
  135. if access == true then
  136. print("Logging in...")
  137. sleep(1)
  138. print("Welcome "..user)
  139. drawDesktop()
  140. deskWait()
  141. elseif access == false then
  142. print("Incorrect username and password combination")
  143. sleep(2)
  144. os.reboot()
  145. end
  146. end
  147.  
  148. drawPreDesktop()
Advertisement
Add Comment
Please, Sign In to add comment