Main/resources/[Developer]/[Anna]/ngd-Bridge/shared/resource.lua
2025-06-07 08:51:21 +02:00

43 lines
No EOL
1.1 KiB
Lua

resource = {}
---Resource Version
---@param name string
---@return string
resource.version = function(name)
local version = GetResourceMetadata(name, 'version', 0)
return version
end
---Resource Version Check
---@param resource string
---@param version string
---@return boolean
resource.isMinimalVersion = function(resource, version)
local currentVersion = GetResourceMetadata(resource, 'version', 0)
if not currentVersion then return false end
local latestVersion = version:match('%d+%.%d+%.%d+')
if not latestVersion or latestVersion == currentVersion then return true end
local cv = { string.strsplit('.', currentVersion) }
local lv = { string.strsplit('.', latestVersion) }
for i = 1, #cv do
local current, minimum = tonumber(cv[i]), tonumber(lv[i])
if current ~= minimum then
if current > minimum then
return true
else
break
end
end
end
return false
end
---Resource Missing
---@param name string
resource.missing = function(name)
return GetResourceState(name) == 'missing'
end