mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-09-12 08:08:30 +02:00
check (maybe working?)
This commit is contained in:
parent
f9ac0e65ec
commit
e5443bc3ce
@ -1,14 +1,26 @@
|
|||||||
function worldeditadditions_core.register_command(def)
|
function worldeditadditions_core.check_command(name, def)
|
||||||
local def = table.copy(def)
|
if not (name and #name > 0) then
|
||||||
assert(name and #name > 0)
|
return false, "Error: No command name."
|
||||||
assert(def.privs)
|
|
||||||
def.require_pos = def.require_pos or 0
|
|
||||||
assert(def.require_pos >= 0 and def.require_pos < 3)
|
|
||||||
if def.params == "" and not def.parse then
|
|
||||||
def.parse = function(params_text) return true end
|
|
||||||
else
|
|
||||||
assert(def.parse)
|
|
||||||
end
|
end
|
||||||
assert(def.nodes_needed == nil or type(def.nodes_needed) == "function")
|
if not def.privs then
|
||||||
assert(def.func)
|
return false, "Error: privs is nill. Expected table."
|
||||||
|
end
|
||||||
|
def.require_pos = def.require_pos or 0
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user