adapt mod to 5.0.0 changes

This commit is contained in:
Dirk Sohler 2019-03-02 18:26:11 +01:00
parent 74944af904
commit 9186bb8de5
No known key found for this signature in database
GPG Key ID: B9751241BD7D4E1A
3 changed files with 14 additions and 21 deletions

@ -1,2 +0,0 @@
default
moreores?

@ -1 +1,4 @@
name = uniham 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 <https://gitlab.com/4w/uniham> for details and documentation

@ -1,9 +1,8 @@
-- Localize & Initialize -- Localize & Initialize
local register_hammer = uniham.register_hammer local register_hammer = uniham.register_hammer
local modpath = uniham.modpath 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 log_prefix = '['..minetest.get_current_modname()..'] '
local registry = modpath..DIR_DELIM..'registry'
-- Check if a file exists -- Check if a file exists
@ -23,22 +22,15 @@ local file_exists = function (file_name)
end end
-- Check if the depends.txt file was read properly -- Load built-in support for supported mods
-- Iterate over all lines local config = Settings(modpath..DIR_DELIM..'mod.conf')
-- Check if the mod exists local depends = config:get('depends')..', '..config:get('optional_depends')
-- Check if a registry file exists
-- dofile() the file and print a log message for modname in depends:gmatch('[0-9a-z_-]+') do
if depends ~= nil then local registry_file = registry..DIR_DELIM..modname..'.lua'
local lines = {} if file_exists(registry_file) then
for line in depends:lines() do dofile(registry_file)
local modname = line:gsub('?', '') local message = 'Loaded built-in '..modname..' support'
if minetest.get_modpath(modname) then minetest.log('action', log_prefix..message)
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
end end
end end