From 6aa96556c01e8e67af6b4e7cd0814049cac43646 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sun, 14 Aug 2022 02:23:56 +0200 Subject: [PATCH] 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. --- data/core/command.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/data/core/command.lua b/data/core/command.lua index 866cf04a..f5738304 100644 --- a/data/core/command.lua +++ b/data/core/command.lua @@ -45,7 +45,9 @@ end function command.add(predicate, map) predicate = command.generate_predicate(predicate) 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 } end end