From 64cd6482d433cb60f2fe4de756e0e10c1267d1b6 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 18 Nov 2023 10:17:52 +0100 Subject: [PATCH] added better mod version comparison --- src/core/Global.ttslua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index f98801f5..d0727557 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -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