mirror of
https://github.com/mt-mods/homedecor_modpack.git
synced 2024-12-23 00:20:17 +01:00
make error messages more useful for nodebox lookups
This commit is contained in:
parent
a97bbbc23e
commit
64a81ebf7a
@ -21,14 +21,17 @@ homedecor.nodebox = {
|
|||||||
local mt = {}
|
local mt = {}
|
||||||
mt.__index = function(table, key)
|
mt.__index = function(table, key)
|
||||||
local ref = homedecor.box[key]
|
local ref = homedecor.box[key]
|
||||||
if type(ref) == "function" then
|
local ref_type = type(ref)
|
||||||
|
if ref_type == "function" then
|
||||||
return function(...)
|
return function(...)
|
||||||
return { type = "fixed", fixed = ref(...) }
|
return { type = "fixed", fixed = ref(...) }
|
||||||
end
|
end
|
||||||
elseif type(ref) == "table" then
|
elseif ref_type == "table" then
|
||||||
return { type = "fixed", fixed = ref }
|
return { type = "fixed", fixed = ref }
|
||||||
|
elseif ref_type == "nil" then
|
||||||
|
error(key .. "could not be found among nodebox presets and functions")
|
||||||
end
|
end
|
||||||
error("unexpected datatype " .. tostring(type(ref)))
|
error("unexpected datatype " .. tostring(type(ref)) .. " while looking for " .. key)
|
||||||
end
|
end
|
||||||
setmetatable(homedecor.nodebox, mt)
|
setmetatable(homedecor.nodebox, mt)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user