2022-04-19 01:09:22 +10:00
function lib . checkDependency ( resource , minimumVersion , printMessage )
2022-02-28 02:40:25 +00:00
local currentVersion = GetResourceMetadata ( resource , ' version ' , 0 ) : match ( ' %d%.%d+%.%d+ ' )
2022-08-22 20:53:55 +10:00
if currentVersion ~= minimumVersion then
local cv = { string.strsplit ( ' . ' , currentVersion ) }
local mv = { string.strsplit ( ' . ' , minimumVersion ) }
2022-04-19 01:09:22 +10:00
local msg = ( " ^1%s requires version '%s' of '%s' (current version: %s)^0 " ) : format ( GetInvokingResource ( ) or GetCurrentResourceName ( ) , minimumVersion , resource , currentVersion )
2022-08-22 20:53:55 +10:00
for i = 1 , # cv do
if tonumber ( cv [ i ] ) < tonumber ( mv [ i ] ) then
if printMessage then
return print ( msg )
end
2022-04-19 01:09:22 +10:00
2022-08-22 20:53:55 +10:00
return false , msg
end
end
2022-02-28 02:40:25 +00:00
end
return true
end