Advertisement
Guest User

kernel.lua

a guest
Feb 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.21 KB | None | 0 0
  1. --Vars
  2. local BigMonitor = "monitor_3"
  3. local SmallMonitors = { "monitor_0", "monitor_2" }
  4.  
  5. local bmon = peripheral.wrap(BigMonitor)
  6. local mons = {}
  7. local kos = {}
  8. local user = {}
  9.  
  10. local curuser = nil--"root"--nil
  11. local mde = nil
  12.  
  13. user["root"] = { true, "pin123" }
  14. user["Byloff"] = { false, "4850" }
  15.  
  16. os.setComputerLabel("C1")
  17.  
  18. for k, v in pairs(SmallMonitors) do
  19.     mons[k] = peripheral.wrap(v)
  20. end
  21.  
  22. function drawText(mon, txt, scale)
  23.     mon.clear()
  24.    
  25.     local w, h = mon.getSize()
  26.     mon.setCursorPos( math.ceil( w/2 - #txt/2) + 1, h/2 + 1 )
  27.    
  28.     mon.setTextScale(scale)
  29.     mon.write(txt)
  30.    
  31.     --mon.setCursorPos(curx,cury+1)
  32. end
  33.  
  34. function displayText(txt)
  35.     drawText(bmon, txt, 5)
  36.    
  37.     for i=1, #mons do
  38.         drawText(mons[i], txt, 1)
  39.     end
  40. end
  41.  
  42. function kos.print(txt, a)
  43.     write(os.getComputerLabel() .. txt)
  44.     if a == nil then
  45.         print("")
  46.     end
  47. end
  48.  
  49. function kos.stdline(a)
  50.     kos.print("@", true)
  51.     if user[curuser][1] == true then
  52.         term.setTextColor(colors.red)
  53.     else
  54.         term.setTextColor(colors.lime)
  55.     end
  56.     write(curuser)
  57.     term.setTextColor(colors.white)
  58.     write(":~$ ")
  59.    
  60.     if a == nil then
  61.         print("")
  62.     end
  63. end
  64.  
  65. term.clear()
  66. --print("KSpace-OS V1")
  67. --term.setCursorPos(1,0)
  68. --print ("Enter Password")
  69. --local input = read("*")
  70.  
  71. displayText("10")
  72.  
  73. function kos.next()
  74.     kos.stdline(true)
  75.     term.setCursorBlink(true)
  76.     local cmd = read()
  77.     term.setCursorBlink(false)
  78.    
  79.     kos.next()
  80. end
  81.  
  82. function kos.passentry()
  83.     if type(curuser) == "string" then
  84.         term.clear()
  85.        
  86.         boot()
  87.     else
  88.         --print(type(mde))
  89.         if type(mde) == "nil" then
  90.             kos.print("@username: ", true)
  91.            
  92.             local name = read()
  93.             term.setCursorBlink(true)
  94.             if type(user[name]) == "table" then
  95.                 mde = name
  96.                
  97.                 term.setCursorBlink(false)
  98.                 kos.passentry()
  99.             else
  100.                 term.setCursorBlink(false)
  101.                 kos.print(": incorrect username!")
  102.                 kos.passentry()
  103.             end
  104.         else
  105.             kos.print("@password: ", true)
  106.            
  107.             term.setCursorBlink(true)
  108.             local password = read("*")
  109.             local usr = user[mde]
  110.             --print(mde)
  111.             if password == usr[2] then
  112.                 term.setCursorBlink(false)
  113.                 curuser = mde
  114.                
  115.                 kos.passentry()
  116.                 --term.clear()
  117.                 --boot()
  118.             else
  119.                 term.setCursorBlink(false)
  120.                 kos.print(": incorrect password!")
  121.                
  122.                 kos.passentry()
  123.             end
  124.         end
  125.     end
  126. end
  127.  
  128. function boot()
  129.     term.setCursorPos(1, 1)
  130.     term.setTextColor(colors.yellow)
  131.     print("KronosOS V1")
  132.     print("Dist. SpaceX-OS")
  133.     print("(C) Kronos Tech Inc.")
  134.    
  135.     term.setTextColor(colors.white)
  136.     term.setCursorBlink(false)
  137.    
  138.     print("")
  139.     if type(curuser) == "string" then
  140.         --print("hi")
  141.         kos.next()
  142.     else
  143.         kos.passentry()
  144.     end
  145. end
  146.  
  147. boot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement