2018-09-22 16:12:22 +02:00
|
|
|
-- Localize & Initialize
|
|
|
|
local register_hammer = uniham.register_hammer
|
|
|
|
local modpath = uniham.modpath
|
|
|
|
local log_prefix = '['..minetest.get_current_modname()..'] '
|
2019-03-02 18:26:11 +01:00
|
|
|
local registry = modpath..DIR_DELIM..'registry'
|
2018-09-22 16:12:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
-- Check if a file exists
|
|
|
|
--
|
|
|
|
-- This function validates the existence of a file by trying to open the file
|
|
|
|
-- for reading. If this succeeds the file is present.
|
|
|
|
--
|
|
|
|
-- @param file_name The file name (path) to be checked
|
|
|
|
local file_exists = function (file_name)
|
|
|
|
local f = io.open(file_name ,'r')
|
|
|
|
if f ~= nil then
|
|
|
|
io.close(f)
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2019-03-02 18:26:11 +01:00
|
|
|
-- 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'
|
2019-03-02 18:36:12 +01:00
|
|
|
if file_exists(registry_file) and minetest.get_modpath(modname) then
|
2019-03-02 18:26:11 +01:00
|
|
|
dofile(registry_file)
|
|
|
|
local message = 'Loaded built-in '..modname..' support'
|
|
|
|
minetest.log('action', log_prefix..message)
|
2018-09-22 16:12:22 +02:00
|
|
|
end
|
|
|
|
end
|