Advertisement
Mackan90096

need help

Mar 29th, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.41 KB | None | 0 0
  1. bar1 = paintutils.loadImage(".bar1")
  2. logo = paintutils.loadImage(".logo")
  3. icon = paintutils.loadImage(".icon")
  4. tBarC = 8
  5. tBartC = 1
  6. backColor = 1
  7. scroll = 0
  8. Version = "Alpha [0.1]"
  9. credCol = 32
  10. firstCol = 1
  11. secCol = 2048
  12. Author  = "Mackan90096"
  13. ErrCol1 = 16384
  14. calcCol = 128
  15.  
  16. --Desktop
  17. term.setBackgroundColor(backColor)
  18. term.clear()
  19.  
  20. slc = 0
  21.  
  22.  
  23.  
  24. function credits()
  25. term.clear()
  26. term.setCursorPos(1,1)
  27. term.setTextColor(credCol)
  28. print("Credits")
  29. term.setCursorPos(1,3)
  30. print("Programs and apis:")
  31. term.setCursorPos(1,5)
  32. print("CCalendar - TheOriginalBIT")
  33. term.setCursorPos(1,6)
  34. print("Passgen -  Conn332")
  35. term.setCursorPos(1,7)
  36. print("CCleverbot - 1lann and GravityScore")
  37. term.setCursorPos(1,9)
  38. print("Help in development:")
  39. term.setCursorPos(1,11)
  40. print("All the great people that helped me on the forums! - You know who you are :)")
  41. term.setCursorPos(1,13)
  42. write("To return type anything and hit enter: ")
  43. local input = read()
  44. if input == "1" then
  45. term.clear()
  46. drawDesktop()
  47. else
  48. term.clear()
  49. drawDesktop()
  50. end
  51. end
  52.  
  53. function login()
  54. term.clear()
  55. term.setCursorPos(1,1)
  56. print("Logging in")
  57. term.setCursorPos(1,3)
  58. write("Username: ")
  59. usrName = read()
  60. write("Password: ")
  61. local pass = read("*")
  62. file = fs.open("users/"..usrName,"r")
  63. if not fs.exists("users/"..usrName) then
  64. term.clear()
  65. term.setCursorPos(1,1)
  66. print("Login failed")
  67. sleep(1)
  68. term.clear()
  69. drawDesktop()
  70. elseif fs.exists("users/"..usrName) then
  71. local fileData = {}
  72. local line = file.readLine()
  73. repeat
  74. table.insert(fileData, line)
  75. line = file.readLine()
  76. until line == nil -- readLine()
  77. file.close()
  78. local passFromFile = fileData[1]
  79. if pass == passFromFile then
  80. term.clear()
  81. term.setCursorPos(1,1)
  82. print("Login succeded!")
  83. sleep(1)
  84. term.clear()
  85. drawDesktop2()
  86. slc = 2
  87. else
  88. term.clear()
  89. term.setCursorPos(1,1)
  90. print("Login failed!")
  91. sleep(1)
  92. term.clear()
  93. drawDesktop()
  94. end
  95. end
  96. end
  97.  
  98. function register()
  99. term.clear()
  100. term.setCursorPos(1,1)
  101. print("Registering")
  102. term.setCursorPos(1,3)
  103. write("Username: ")
  104. local usrName = read()
  105. term.setCursorPos(1,4)
  106. write("Password: ")
  107. local pass = read("*")
  108. fs.makeDir("users")
  109. if not fs.exists("users/"..usrName) then
  110. local file = fs.open("users/"..usrName, "a")
  111. file.writeLine(pass)
  112. file.close()
  113. sleep(0.5)
  114. term.clear()
  115. term.setCursorPos(1,1)
  116. print("Registered!")
  117. sleep(0.5)
  118. term.clear()
  119. drawDesktop()
  120. elseif fs.exists("users/"..usrName) then
  121. term.clear()
  122. term.setCursorPos(1,1)
  123. print("Username already in use!")
  124. sleep(1)
  125. term.clear()
  126. drawDesktop()
  127. end
  128. end
  129.  
  130. function titleBar2()
  131.   term.setCursorPos(1,1)
  132.   term.setBackgroundColor(tBarC)
  133.   term.setTextColor(tBartC)
  134.   term.clearLine()
  135.   term.setCursorPos(3,1)
  136.   print("[Begin]")
  137.   term.setCursorPos(12,1)
  138.   print("Logged in as: "..usrName)
  139. end
  140.  
  141. function drawDesktop2()
  142.   slc = 2
  143.   term.setBackgroundColor(backColor)
  144.   term.clear()
  145.   paintutils.drawImage(logo,1,1)
  146.   paintutils.drawImage(icon,2,3)
  147.   titleBar2()
  148. end
  149.  
  150. function drawMenu2()
  151. term.setTextColor(256)
  152. term.setBackgroundColor(128)
  153. term.setCursorPos(1,2)
  154. print("          ")
  155. term.setCursorPos(1,3)
  156. print("Logout    ")
  157. term.setCursorPos(1,4)
  158. print("Calculator")
  159. term.setCursorPos(1,5)
  160. print("Games     ")
  161. term.setCursorPos(1,6)
  162. print("Account   ")
  163. term.setCursorPos(1,7)
  164. print("Calendar  ")
  165. term.setCursorPos(1,8)
  166. print("Email     ")
  167. term.setCursorPos(1,9)
  168. print("Shutdown  ")
  169. term.setCursorPos(1,10)
  170. print("Reboot    ")
  171. term.setCursorPos(1,11)
  172. print("          ")
  173. end
  174.  
  175. function titleBar()
  176.   term.setCursorPos(1,1)
  177.   term.setBackgroundColor(tBarC)
  178.   term.setTextColor(tBartC)
  179.   term.clearLine()
  180.   term.setCursorPos(3,1)
  181.   print("[Begin]")
  182. end
  183.  
  184. function drawDesktop()
  185.   slc = 0
  186.   term.setBackgroundColor(backColor)
  187.   term.clear()
  188.   paintutils.drawImage(logo,1,1)
  189.   titleBar()
  190. end
  191.  
  192. function drawMenu1()
  193. term.setTextColor(256)
  194. term.setBackgroundColor(128)
  195. term.setCursorPos(1,2)
  196. print("          ")
  197. term.setCursorPos(1,3)
  198. print(" Login    ")
  199. term.setCursorPos(1,4)
  200. print(" Register ")
  201. term.setCursorPos(1,5)
  202. print(" Reboot   ")
  203. term.setCursorPos(1,6)
  204. print(" Shutdown ")
  205. term.setCursorPos(1,7)
  206. print(" Passgen  ")
  207. term.setCursorPos(1,8)
  208. print(" Credits  ")
  209. term.setCursorPos(1,9)
  210. print("          ")
  211. end
  212. drawDesktop()
  213.  
  214. while true do
  215. local event, button, X, Y = os.pullEventRaw()
  216.  if slc == 0 then
  217.   if event == "mouse_click" then
  218.    if X >= 2 and X <= 8 and Y == 1 and button == 1 then
  219.     drawMenu1()
  220.     slc = 1    
  221.     drawDesktop()
  222.    end
  223.   end
  224.  elseif slc == 1 then
  225.   if X >= 1 and X <= 11 and button == 1 and Y == 3 then slc = 0
  226.     login()
  227.    elseif X >= 1 and X <= 11 and Y == 4 and button == 1 then slc = 0
  228.    register()
  229.    elseif X >= 1 and X <= 11 and Y == 5 and button == 1 then slc = 0        
  230.    os.reboot()
  231.    elseif X >= 1 and X <= 11 and Y == 6 and button == 1 then slc = 0
  232.    os.shutdown()
  233.    elseif X >= 1 and X <= 11 and Y == 7 and button == 1 then slc = 0
  234.    passgen()
  235.    elseif X >= 1 and X <= 11 and Y == 8 and button == 1 then slc = 0
  236.    credits()
  237.    else slc = 0
  238.    drawDesktop()
  239.  
  240.   end
  241.   elseif slc == 2 then
  242.   if X >= 1 and X <= 11 and button == 1 and Y == 3 then slc = 3
  243.   elseif X >= 2 and X <= 5  and Y >= 3 and Y <= 9 and button == 1 then
  244.      shell.run("file")
  245.  
  246.   else slc = 2
  247.   drawDesktop2()
  248.  end
  249.  elseif slc == 3 then
  250.    if X >= 2 and X <= 8 and Y == 1 and button == 1 then
  251.     drawMenu2()
  252.     slc = 2    
  253.     drawDesktop2()
  254.  end
  255.  
  256. end
  257. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement