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
2022-08-23 19:29:45 +10:00
local cMajor , cMinor = string.strsplit ( ' . ' , currentVersion , 2 )
local mMajor , mMinor = string.strsplit ( ' . ' , minimumVersion , 2 )
2022-04-19 01:09:22 +10:00
2022-08-23 19:29:45 +10:00
local msg = ( " ^1%s requires version '%s' of '%s' (current version: %s)^0 " ) : format ( GetInvokingResource ( ) or GetCurrentResourceName ( ) , minimumVersion , resource , currentVersion )
if tonumber ( cMajor ) < tonumber ( mMajor ) or tonumber ( cMinor ) < tonumber ( mMinor ) then
if printMessage then
return print ( msg )
2022-08-22 20:53:55 +10:00
end
2022-08-23 19:29:45 +10:00
return false , msg
2022-08-22 20:53:55 +10:00
end
2022-02-28 02:40:25 +00:00
end
return true
end