From 9186bb8de50aac0d749696d6b63526bf9b3db24b Mon Sep 17 00:00:00 2001 From: Dirk Sohler Date: Sat, 2 Mar 2019 18:26:11 +0100 Subject: [PATCH] adapt mod to 5.0.0 changes --- depends.txt | 2 -- mod.conf | 3 +++ system/registry.lua | 30 +++++++++++------------------- 3 files changed, 14 insertions(+), 21 deletions(-) delete mode 100644 depends.txt diff --git a/depends.txt b/depends.txt deleted file mode 100644 index 436cd47..0000000 --- a/depends.txt +++ /dev/null @@ -1,2 +0,0 @@ -default -moreores? diff --git a/mod.conf b/mod.conf index 6636165..92d029c 100644 --- a/mod.conf +++ b/mod.conf @@ -1 +1,4 @@ name = uniham +depends = default +optional_depends = moreores +descripton = The mod adds various hammers that can be used to crush nodes and an API to register own hammers. See for details and documentation diff --git a/system/registry.lua b/system/registry.lua index dda598e..b1ab891 100644 --- a/system/registry.lua +++ b/system/registry.lua @@ -1,9 +1,8 @@ -- Localize & Initialize local register_hammer = uniham.register_hammer local modpath = uniham.modpath -local registry = modpath..DIR_DELIM..'registry' -local depends = io.open(modpath..DIR_DELIM..'depends.txt', 'rb') local log_prefix = '['..minetest.get_current_modname()..'] ' +local registry = modpath..DIR_DELIM..'registry' -- Check if a file exists @@ -23,22 +22,15 @@ local file_exists = function (file_name) end --- Check if the depends.txt file was read properly --- Iterate over all lines --- Check if the mod exists --- Check if a registry file exists --- dofile() the file and print a log message -if depends ~= nil then - local lines = {} - for line in depends:lines() do - local modname = line:gsub('?', '') - if minetest.get_modpath(modname) then - local registry_file = registry..DIR_DELIM..modname..'.lua' - if file_exists(registry_file) then - dofile(registry_file) - local message = 'Loaded built-in '..modname..' support' - minetest.log('action', log_prefix..message) - end - end +-- Load built-in support for supported mods +local config = Settings(modpath..DIR_DELIM..'mod.conf') +local depends = config:get('depends')..', '..config:get('optional_depends') + +for modname in depends:gmatch('[0-9a-z_-]+') do + local registry_file = registry..DIR_DELIM..modname..'.lua' + if file_exists(registry_file) then + dofile(registry_file) + local message = 'Loaded built-in '..modname..' support' + minetest.log('action', log_prefix..message) end end