From 3639e9847a3a710a49b25196f29dc3279278935d Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Fri, 1 Nov 2024 19:19:31 +0100 Subject: [PATCH] Add utility to check for build number --- modules/misc.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/misc.lua b/modules/misc.lua index 1ccf6ef..48be7dc 100644 --- a/modules/misc.lua +++ b/modules/misc.lua @@ -9,7 +9,7 @@ local _, namespace = ... --]] -- game version API -local _, _, _, interfaceVersion = GetBuildInfo() +local _, buildVersion, _, interfaceVersion = GetBuildInfo() --[[ namespace:IsRetail() Checks if the current client is running the "retail" version. --]] @@ -31,6 +31,18 @@ function addon:IsClassic() return not addon:IsRetail() and not addon:IsClassicEra() end +--[[ namespace:HasBuild(_buildNumber_[, _interfaceVersion_]) +Checks if the current client is running a build equal to or newer than the specified. +Optionally also check against the interface version. +--]] +function addon:HasBuild(build, interface) + if interface and interfaceVersion < interface then + return + end + + return tonumber(buildVersion) >= build +end + --[[ namespace:ArgCheck(arg, argIndex, type[, type...]) Checks if the argument `arg` at position `argIndex` is of type(s). --]]