Advertisement
Guest User

dankos

a guest
Oct 14th, 2016
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.91 KB | None | 0 0
  1. --os.pullEvent = os.pullEventRaw
  2. --Variables
  3.   local inputU = ("")
  4.   local inputP = ("")
  5.   local os = ("DankOS")
  6.   local osV = ("1.2")
  7.  
  8. --Functions
  9.   function rawread() --Key Input
  10.     while true do
  11.       local sEvent, param = os.pullEvent("key")
  12.       if sEvent == "key" then
  13.         if param == 44 then
  14.           colorC()
  15.           print("Admin override")
  16.           colorW()
  17.           break
  18.         end
  19.       end
  20.     end
  21.   end
  22.  
  23.   function clear() --Clear fucntion
  24.     term.clear()
  25.     term.setCursorPos(1,1)
  26.   end
  27.  
  28.   function loadingS() --Loading screen
  29.     colorC()
  30.     textutils.slowPrint("<==========>", 10)
  31.     colorW()
  32.     sleep(1)    
  33.   end
  34.  
  35.   function bootS() --Boot screen
  36.     clear()
  37.     colorC()
  38.     print("|----------|")
  39.     write("|"..os)
  40.     print(" "..osV.."|")
  41.     print("|----------|")
  42.     colorW()
  43.   end
  44.  
  45.   function loginS() --Login screen
  46.     file = fs.open("os/.User/"..passwordR,"r")
  47.     local fileDataP = {}
  48.     local line = file.readLine()
  49.     repeat
  50.     table.insert(fileDataP, line)
  51.     line = file.readLine()
  52.     until line == nil
  53.     file.close()
  54.     local pass = fileDataP[1]
  55.     -- ------------------
  56.     file = fs.open("os/.User/"..usernameR,"r")
  57.     local fileDataU = {}
  58.     local line = file.readLine()
  59.     repeat
  60.     table.insert(fileDataU,line)
  61.     line = file.readLine()
  62.     until line == nil
  63.     file.close()
  64.     local user = fileDataU[1]
  65.     -- -------------------
  66.     clear()
  67.     colorC()
  68.     print("Welcome!")
  69.     write("Username: ")
  70.     colorY()
  71.     inputU = read()
  72.     if inputU == user then
  73.       colorG()
  74.       print("Correct")
  75.       colorW()
  76.     end
  77.     if inputU ~= user then
  78.       colorR()
  79.       print("Incorrect!")
  80.       colorW()
  81.       sleep(1)
  82.       loginS()
  83.     end
  84.     colorC()
  85.     write("Password: ")
  86.     colorY()
  87.     inputP = read("*")
  88.     if inputP == pass then
  89.       colorG()
  90.       print("Correct") --Correct password
  91.       colorW()
  92.       sleep(1)
  93.       clear()
  94.     end
  95.     if inputP ~= pass then --Incorrect password
  96.       colorR()
  97.       print("Incorrect!")
  98.       colorW()
  99.       sleep(1)
  100.       loginS()
  101.     end
  102.   end
  103.  
  104.   function mainS() --Main screen
  105.     bootS()
  106.        
  107.   end
  108.  
  109.   function yN() --Yes/No function "Ugly Code"
  110.   local n=1
  111.   while true do
  112.   local x, y=term.getCursorPos()
  113.   term.clearLine()
  114.   if n==1 then write(">YES<   NO") else write (" YES   >NO<") end
  115.   term.setCursorPos(x, y)
  116.   a, b=os.pullEvent()  
  117.   while a~="key" do a, b=os.pullEvent() end
  118.   if b==203 and n==2 then n=1 end
  119.   if b==205 and n==1 then n=2 end
  120.   if b==28 then print("") break end
  121.   end
  122.   if n==1 then return true end
  123.   if n==2 then return false end
  124.   return false
  125.   end
  126.  
  127.   function startS() --Startup screen
  128.     clear()
  129.     colorC()
  130.     write("Welcome to "..os)
  131.     print(" "..osV)
  132.     print("Do you want to create a user Y/N?")
  133.     colorY()
  134.     colorW()
  135.    
  136.   end
  137.  
  138.   function regS() --Register screen
  139.     clear()
  140.     colorC()
  141.     bootS()
  142.     print("Time to create a new user")
  143.     colorC()
  144.     write("Username: ")
  145.     colorY()
  146.     usernameR = read()
  147.     colorC()
  148.     write("Password: ")
  149.     colorY()
  150.     passwordR = read()
  151.     colorW()
  152.    
  153.    
  154.     fs.makeDir("os/.User")
  155.     fs.makeDir("os/.User")
  156.     local file = fs.open("os/.User/"..usernameR,"a")
  157.     file.writeLine(usernameR)
  158.     file.close()
  159.     local file = fs.open("os/.User/"..passwordR, "a")
  160.     file.writeLine(passwordR)
  161.     file.close()
  162.   end
  163.  
  164.  
  165.   function colorW() -- White color
  166.     term.setTextColor(colors.white)
  167.   end
  168.  
  169.   function colorG() --Green color
  170.     term.setTextColor(colors.green)
  171.   end
  172.  
  173.   function colorR() --Red color
  174.     term.setTextColor(colors.red)
  175.   end
  176.  
  177.   function colorC() --Cyan color
  178.     term.setTextColor(colors.cyan)
  179.   end
  180.  
  181.   function colorY() --Yellow color
  182.     term.setTextColor(colors.yellow)
  183.   end
  184.  
  185.  
  186. --Main stuff
  187. startS()
  188. bootS()
  189. colorW()
  190. sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement