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:
Guldoman
2022-08-16 22:18:50 +02:00
parent d944bd85ec
commit 6aa96556c0
+3 -1
View File
@@ -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