From e1bfb7cc797d0709b0b5ff8fe514ebec6ebd7ec0 Mon Sep 17 00:00:00 2001 From: SX Date: Mon, 7 Dec 2020 04:30:10 +0200 Subject: [PATCH] (#62) Add version information to metatool namespace --- metatool/init.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/metatool/init.lua b/metatool/init.lua index 709e45b..ddb3f6c 100644 --- a/metatool/init.lua +++ b/metatool/init.lua @@ -13,15 +13,28 @@ -- initialize namespace and core functions metatool = { + version_str = "2.0.0", + version = nil, configuration_file = minetest.get_worldpath() .. '/metatool.cfg', export_default_config = minetest.settings:get_bool("metatool_export_default_config", true), modpath = minetest.get_modpath('metatool'), S = string.format } + +local version_matcher = metatool.version_str:gmatch("%d+") +metatool.version = { + major = tonumber(version_matcher()), + minor = tonumber(version_matcher()), + patch = tonumber(version_matcher()), +} +assert(type(metatool.version.major) == "number", "Invalid Metatool version_str major") +assert(type(metatool.version.minor) == "number", "Invalid Metatool version_str minor") +assert(type(metatool.version.patch) == "number", "Invalid Metatool version_str patch") + dofile(metatool.modpath .. '/util.lua') dofile(metatool.modpath .. '/settings.lua') dofile(metatool.modpath .. '/api.lua') dofile(metatool.modpath .. '/command.lua') dofile(metatool.modpath .. '/formspec.lua') -print('[OK] MetaTool loaded') +print('[OK] MetaTool ' .. metatool.version_str .. ' loaded')