Minetest-WorldEditAdditions/worldeditadditions_core/register/check.lua

27 lines
822 B
Lua
Raw Normal View History

2021-08-03 01:54:33 +00:00
function worldeditadditions_core.check_command(name, def)
if not (name and #name > 0) then
return false, "Error: No command name."
end
if not def.privs then
return false, "Error: privs is nill. Expected table."
end
2021-06-30 01:53:14 +00:00
def.require_pos = def.require_pos or 0
2021-08-03 01:54:33 +00:00
if not (def.require_pos >= 0 and def.require_pos < 3) then
return false, "Error: require_pos must be greater than -1 and less than 3."
end
if not def.parse then
if def.params == "" then
def.parse = function(params_text) return true end
else
return false, "Error: parse function is invalid."
end
end
if not (def.nodes_needed == nil or type(def.nodes_needed) == "function") then
return false, "Error: nodes_needed must be nil or function."
end
if not def.func then
return false, "Error: main function is invalid."
end
return true
2021-06-30 01:53:14 +00:00
end