refactor(resource/version): checkDependency optional print and return

Send 'true' to match old behaviour (print message, return nil).
New behaviour has no output unless sending a third argument.
This commit is contained in:
Linden
2022-04-19 01:09:22 +10:00
parent f4e0739b04
commit 84ad4abcca

View File

@@ -1,8 +1,14 @@
function lib.checkDependency(resource, minimumVersion)
function lib.checkDependency(resource, minimumVersion, printMessage)
local currentVersion = GetResourceMetadata(resource, 'version', 0):match('%d%.%d+%.%d+')
if currentVersion < minimumVersion then
return print(("^1%s requires version '%s' of '%s' (current version: %s)^0"):format(GetInvokingResource() or GetCurrentResourceName(), minimumVersion, resource, currentVersion))
local msg = ("^1%s requires version '%s' of '%s' (current version: %s)^0"):format(GetInvokingResource() or GetCurrentResourceName(), minimumVersion, resource, currentVersion)
if printMessage then
return print(msg)
end
return false, msg
end
return true