Advertisement
Pirnogion

OC/SystemRequirements

Aug 21st, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | None | 0 0
  1. local component  = require "component"
  2. local computer   = require "computer"
  3. local filesystem = require "filesystem"
  4. local shell      = require "shell"
  5.  
  6. local MEMORY_TIER_LIST = {
  7.     ["tier1"] = 196608,
  8.     ["tier15"] = 262144,
  9.     ["tier2"] = 393216,
  10.     ["tier25"] = 524288,
  11.     ["tier3"] = 786432,
  12.     ["tier35"] = 1048576
  13. }
  14.  
  15. local HARD_TIER_LIST = {
  16.     ["tier1"] = 1048576,
  17.     ["tier2"] = 2097152,
  18.     ["tier3"] = 4194304
  19. }
  20.  
  21. local GPU_TIER_LIST = {
  22.     ["tier1"] = 1,
  23.     ["tier2"] = 4,
  24.     ["tier3"] = 8
  25. }
  26.  
  27. local function getAllHDD()
  28.     local args, options = shell.parse(threedot)
  29.  
  30.     local candidates = {}
  31.     for address in component.list("filesystem", true) do
  32.       local dev = component.proxy(address)
  33.       if not dev.isReadOnly() and dev.address ~= computer.tmpAddress() then
  34.         table.insert(candidates, dev)
  35.       end
  36.     end
  37.  
  38.     return candidates
  39. end
  40.  
  41. --Check system requirements
  42. local function checkMemory(require_memory)
  43.     if ( computer.totalMemory() >= require_memory) then
  44.         return true
  45.     end
  46.  
  47.     return false
  48. end
  49.  
  50. local function checkHDD(require_hdd_size)
  51.     local hdds = getAllHDD()
  52.     local totalHDDSize = 0
  53.     for i = 1, #hdds do
  54.         totalHDDSize = totalHDDSize + hdds[i].spaceTotal()
  55.     end
  56.  
  57.     if ( totalHDDSize >= require_hdd_size ) then
  58.         return true
  59.     end
  60.  
  61.     return false
  62. end
  63.  
  64. local function checkGPU(tier, count)
  65.     local graphicCards = component.list("gpu")
  66.     local len = 0
  67.  
  68.     --Get graphicCards len
  69.     --#graphicCards not worked
  70.     for i in graphicCards do
  71.         len = len + 1
  72.     end
  73.  
  74.     if ( len >= count ) then
  75.         for address in graphicCards do
  76.             if ( component.proxy(address).maxDepth() >= tier ) then
  77.                 return true
  78.             end
  79.         end
  80.     end
  81.  
  82.     return false
  83. end
  84.  
  85. local function checkSystemRequirements()
  86.     local memory = checkMemory(MEMORY_TIER_LIST.tier25)
  87.     local hddSize = checkHDD(HARD_TIER_LIST.tier3)
  88.     local gpuTier = checkGPU(GPU_TIER_LIST.tier3, 1)
  89.  
  90.     print(memory, " : ", hddSize, " : ", gpuTier)
  91.  
  92.     if ( memory and hddSize and gpuTier ) then
  93.         return true
  94.     end
  95.  
  96.     return false
  97. end
  98.  
  99. print( checkSystemRequirements() )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement