1
0
Fork 0

Definition validation improved

This commit is contained in:
the-real-herowl 2024-05-01 21:50:05 +02:00
parent a25e2b8eb3
commit b9428e3438
1 changed files with 10 additions and 9 deletions

View File

@ -9,16 +9,17 @@ 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]) ~= "boolean" and type(defs[i]) ~= "nil" then
error("Invalid arg #5")
end
else
if type(defs[i]) ~= "string" then if type(defs[i]) ~= "string" then
error("Invalid arg #".. tostring(i)) error("defs["..i.."] must be a string")
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 end
local name = defs[1] local name = defs[1]