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
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
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
-- 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
end
end