added better mod version comparison

This commit is contained in:
Chr1Z93 2023-11-18 10:17:52 +01:00
parent ffe86bd684
commit 64cd6482d4

View File

@ -1420,8 +1420,8 @@ function compareVersion(request)
-- global variable to make it accessible for other functions
modMeta = JSON.decode(request.text)
-- stop here if on latest version
if MOD_VERSION == modMeta["latestVersion"] then return end
-- stop here if on latest or newer version
if convertVersionToNumber(MOD_VERSION) >= convertVersionToNumber(modMeta["latestVersion"]) then return end
-- stop here if "don't show again" was clicked for this version before
if acknowledgedUpgradeVersions[modMeta["latestVersion"]] then return end
@ -1432,6 +1432,13 @@ function compareVersion(request)
Wait.time(function() UI.show("FinnIcon") end, 1)
end
-- converts a version number to a string
---@param version String Version number, separated by dots (e.g. 3.3.1)
function convertVersionToNumber(version)
local major, minor, patch = string.match(version, "(%d+)%.(%d+)%.(%d+)")
return major * 100 + minor * 10 + patch
end
-- updates the XML update notification based on the mod metadata
function updateNotificationLoading()
-- grab data