Replace assert with core.log_quiet on command replace
This caused issues when saving the user module with commands defined inside it, as it resulted in the user-defined commands trying to overwrite themselves and failing.
This commit is contained in:
@@ -45,7 +45,9 @@ end
|
|||||||
function command.add(predicate, map)
|
function command.add(predicate, map)
|
||||||
predicate = command.generate_predicate(predicate)
|
predicate = command.generate_predicate(predicate)
|
||||||
for name, fn in pairs(map) do
|
for name, fn in pairs(map) do
|
||||||
assert(not command.map[name], "command already exists: " .. name)
|
if command.map[name] then
|
||||||
|
core.log_quiet("Replacing existing command \"%s\"", name)
|
||||||
|
end
|
||||||
command.map[name] = { predicate = predicate, perform = fn }
|
command.map[name] = { predicate = predicate, perform = fn }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user