changeset 63:00bf6d4f9238

Initial support for modules checking minimum requirements.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Fri, 20 Apr 2012 04:14:36 +0000
parents d5fe3482db67
children 359d0159d6ca
files core.lua
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/core.lua	Fri Apr 20 03:29:24 2012 +0000
+++ b/core.lua	Fri Apr 20 04:14:36 2012 +0000
@@ -723,6 +723,29 @@
 	--function addon:OnModuleCreated (plugin)
 	--	print("created plugin", plugin:GetName())
 	--end
+
+	local olrev = tonumber("@project-revision@") or 0
+	local err = "Module '%s' did not load because it failed a required condition: '%s'"
+	function addon:ConstrainedNewModule (modname, minrev, mincomm, mindata)
+		if not addon.author_debug then
+			if minrev and minrev < olrev then
+				self:Print(err,modname,
+					"revision "..olrev.." older than minimum "..minrev)
+				return false
+			end
+			if mincomm and mincomm < tonumber(self.commrev) then
+				self:Print(err,modname,
+					"commrev "..self.commrev.." older than minimum "..mincomm)
+				return false
+			end
+			if mindata and mindata < opts.datarev then
+				self:Print(err,modname,
+					"datarev "..opts.datarev.." older than minimum "..mindata)
+				return false
+			end
+		end
+		return self:NewModule(modname)
+	end
 end