Definition validation improved

This commit is contained in:
the-real-herowl 2024-05-01 21:50:05 +02:00
parent a25e2b8eb3
commit b9428e3438

View file

@ -9,17 +9,18 @@ function vl_hollow_logs.register_hollow_log(defs)
error("Incomplete definition provided") error("Incomplete definition provided")
end end
for i = 1, #defs do for i = 1, 4 do
if i == 5 then if type(defs[i]) ~= "string" then
if type(defs[i]) ~= "boolean" and type(defs[i]) ~= "nil" then error("defs["..i.."] must be a string")
error("Invalid arg #5")
end
else
if type(defs[i]) ~= "string" then
error("Invalid arg #".. tostring(i))
end
end end
end end
if defs[5] and type(defs[5]) ~= "boolean" then
error("defs[5] must be a boolean if present")
end
if #defs > 5 then
minetest.log("warning", "[vl_hollow_logs] unused vars passed, dumping the table")
minetest.log("warning", dump(defs))
end
local name = defs[1] local name = defs[1]
local stripped_name = defs[2] local stripped_name = defs[2]