Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. ----- RUX_OS(v0.1) --- TripleHeartGaming -----
  2.  
  3. --Local_Variables--
  4. local osVer = "v0.1"
  5. local osLabel = "----- RUX_OS(" .. osVer ..") --- TripleHeartGaming -----"
  6. local closeOS = false
  7. local firstRun = true
  8. local userDatabase = "/disk/Rux_OS/Data/users/"
  9. local users = {}
  10. local curUser = nil
  11. local apiFileDir = "/disk/Rux_OS/APIs/"
  12. local apiFileSearch = "/disk/Rux_OS/APIs/*"
  13. local apiList = fs.find(apiFileSearch)
  14. local loggedIn = false
  15. local defaultUser = "user"
  16. local defaultPass = "Pass123"
  17. --End_Local_Variables--
  18.  
  19. --OS_Functions--
  20. ---Local_Functions---
  21. local function LoadAPIs()
  22. local startTime = os.clock()
  23. local apiCount = #apiList
  24. local failCount = 0
  25. local failList = {}
  26.  
  27. term.clear()
  28. term.setCursorPos(1,1)
  29. print("Loading Rux_OS APIs ...")
  30.  
  31. for i=1,#apiList,1 do
  32. local tmpAPI = string.sub(apiList[i], #apiFileDir)
  33. print("Loading - " , tmpAPI)
  34. if os.loadAPI(apiList[i]) then
  35. print ("API : ", tmpAPI, " has been loaded!")
  36. else
  37. --TODO:: Log error here
  38. print ("API : ", tmpAPI, " has failed to load!")
  39. failCount = failCount + 1
  40. failList[failCount].name = tmpAPI
  41. failList[failCount].path = apiList[i]
  42. end
  43. end
  44. local endTime = os.clock()
  45. local loadTime = endTime - startTime
  46. print("------APIs loaded in - ", loadTime, " seconds!------")
  47. term.setTextColor(colors.green)
  48. print("--APIs Loaded : ", apiCount - failCount)
  49. if failCount > 0 then
  50. term.setTextColor(colors.red)
  51. print("--APIs Failed : ", failCount)
  52. for i=1,failCount,1 do
  53. --TODO:: LOG ERROR TO FILE
  54. write("--", failList[i].name)
  55. end
  56. write("\r\n")
  57. else
  58. term.setTextColor(colors.green)
  59. print("--All APIs have loaded succesfully!")
  60. end
  61. end
  62.  
  63. local function LoginMenu()
  64. Monitor.ResetTerm()
  65. setTextColor(colors.green)
  66. local buttonList = {}
  67. print("Welcome to Rux_OS" .. osVer .. "!")
  68. buttonList[1] = Input.CreateButton("Login")
  69. print(login.text)
  70. buttonList[2] = Input.CreateButton("Create Account")
  71. print(createAccount.text)
  72. buttonList[3] = Input.CreateButton("Exit")
  73. print(ExitB.text)
  74.  
  75.  
  76. local complete = false
  77.  
  78. while not complete do
  79. local event, param1, param2 = Input.GetInput(false, buttonList)
  80.  
  81. if event == Input.iType.keydown and param1 == CKeys.end then
  82.  
  83. elseif event == Input.iType.mousedown and param1 then
  84. if param2 == 1 then
  85. Login()
  86. elseif param2 == 2 then
  87. CreateUser()
  88. elseif param2 == 3 then
  89. if ConfirmOSClose() then
  90. closeOS = true
  91. return
  92. end
  93. end
  94. end
  95.  
  96. end
  97. end
  98.  
  99. function ConfirmOSClose()
  100. print("Are you sure you want to close Rux_OS?[y/n]")
  101. local input = read()
  102. if input = "y" then
  103. return true
  104. else
  105. return false
  106. end
  107. end
  108.  
  109. --ENTRYPOINT--
  110. while not closeOS do
  111. print(osLabel)
  112.  
  113. LoadAPIs()
  114. LoadUsers()
  115. LoginMenu()
  116.  
  117. if closeOS then
  118. return
  119. end
  120.  
  121. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement