Advertisement
Guest User

Rux_OS

a guest
Feb 28th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 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 userConfigData = {}
  10. local users = {}
  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.  
  20. --Global_Variables--
  21. --Periph Connection Data
  22. pConnections = {}
  23. pConnections.obj = {}
  24. pConnections.type = {}
  25. pConnections.side = {}
  26. --End_Global_Variables--
  27.  
  28. --OS_Functions--
  29. ---Local_Functions---
  30.  
  31.  
  32.  
  33. local function LoadAPIs()
  34.     local startTime = os.clock()
  35.     local apiCount = #apiList
  36.     local failCount = 0
  37.     local failList = {}
  38.  
  39.     term.clear()
  40.     term.setCursorPos(1,1)
  41.     print("Loading Rux_OS APIs ...")
  42.  
  43.     for i=1,#apiList,1 do
  44.         local tmpAPI = string.sub(apiList[i], #apiFileDir)
  45.         print("Loading - " , tmpAPI)
  46.         if os.loadAPI(apiList[i]) then
  47.             print ("API : ", tmpAPI, "  has been loaded!")
  48.         else
  49.             --TODO:: Log error here
  50.             print ("API : ", tmpAPI, "  has failed to load!")
  51.             failCount = failCount + 1
  52.             failList[failCount].name = tmpAPI
  53.             failList[failCount].path = apiList[i]
  54.         end
  55.     end
  56.     local endTime = os.clock()
  57.     local loadTime = endTime - startTime
  58.     print("------APIs loaded in - ", loadTime, " seconds!------")
  59.     term.setTextColor(colors.green)
  60.     print("--APIs Loaded : ", apiCount - failCount)
  61.     if failCount > 0 then
  62.         term.setTextColor(colors.red)
  63.         print("--APIs Failed : ", failCount)
  64.         for i=1,failCount,1 do
  65.             --TODO:: LOG ERROR TO FILE
  66.             write("--", failList[i].name)
  67.         end
  68.         write("\r\n")
  69.     else
  70.         term.setTextColor(colors.green)
  71.         print("--All APIs have loaded succesfully!")
  72.     end
  73. end
  74.  
  75. function LoadUserData()
  76.     local cursorStartX,cursorStartY = term.getCursorPos()
  77.     local userList = fs.find(userDatabase)
  78.     local userCount = #userList
  79.     local userId = {}
  80.    
  81.     for i=1,userCount,1 do
  82.   term.setCursorPos(cursorStartX,cursorStartY)
  83.   term.clearLine()
  84.   print("--Loading Users-- (", i , "/", #userDatabase, ")")
  85.         userId[i] = string.sub(userList[i],1, #userDatabase - 1)
  86.   LoadUserConfig(userId[i])
  87.  return userId
  88. end
  89.  
  90. function LoadUserConfig(userID)
  91.     --TODO
  92. end
  93.  
  94. --ENTRYPOINT--
  95. while not closeOS do
  96.     print(osLabel)
  97.  
  98.     LoadAPIs()
  99.     LoadUserData()
  100.    
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement