mirror of
https://github.com/appgurueu/modlib.git
synced 2024-12-22 21:32:27 +01:00
Turn conf.build_tree error into warning
This commit is contained in:
parent
7989f40615
commit
b974113fa9
2
init.lua
2
init.lua
@ -119,7 +119,7 @@ end
|
||||
local rawget, rawset = rawget, rawset
|
||||
modlib = setmetatable({
|
||||
-- TODO bump on release
|
||||
version = 94,
|
||||
version = 95,
|
||||
modname = minetest and minetest.get_current_modname(),
|
||||
_RG = setmetatable({}, {
|
||||
__index = function(_, index)
|
||||
|
@ -1,11 +1,13 @@
|
||||
-- Localize globals
|
||||
local assert, dump, error, ipairs, minetest, modlib, pairs, pcall, table, tonumber, type = assert, dump, error, ipairs, minetest, modlib, pairs, pcall, table, tonumber, type
|
||||
local assert, dump, error, ipairs, minetest, modlib, pairs, pcall, table, tonumber, type, unpack = assert, dump, error, ipairs, minetest, modlib, pairs, pcall, table, tonumber, type, unpack
|
||||
|
||||
-- Set environment
|
||||
local _ENV = {}
|
||||
setfenv(1, _ENV)
|
||||
|
||||
-- not deprecated
|
||||
-- TODO find a better way to deal with settings used as both parent & leaf, ideally preserving the data of both (store in boolean field?)
|
||||
local warn_parent_leaf = "modlib.minetest.conf.build_tree: setting %s used both as parent setting and as leaf, ignoring children"
|
||||
function build_tree(dict)
|
||||
local tree = {}
|
||||
for key, value in pairs(dict) do
|
||||
@ -15,8 +17,17 @@ function build_tree(dict)
|
||||
local index = tonumber(path[i]) or path[i]
|
||||
subtree[index] = subtree[index] or {}
|
||||
subtree = subtree[index]
|
||||
if type(subtree) ~= "table" then
|
||||
minetest.log("warning", warn_parent_leaf:format(table.concat({unpack(path, 1, i)}, ".")))
|
||||
break
|
||||
end
|
||||
end
|
||||
if type(subtree) == "table" then
|
||||
if type(subtree[path[#path]]) == "table" then
|
||||
minetest.log("warning", warn_parent_leaf:format(key))
|
||||
end
|
||||
subtree[path[#path]] = value
|
||||
end
|
||||
subtree[path[#path]] = value
|
||||
end
|
||||
return tree
|
||||
end
|
||||
@ -303,4 +314,4 @@ function check_constraints(value, constraints)
|
||||
end
|
||||
|
||||
-- Export environment
|
||||
return _ENV
|
||||
return _ENV
|
||||
|
Loading…
Reference in New Issue
Block a user