builtin: Correctly indicate failure in /spawnentity
authorsfan5 <sfan5@live.de>
Sun, 26 Apr 2020 18:34:10 +0000 (20:34 +0200)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Mon, 27 Apr 2020 04:58:34 +0000 (06:58 +0200)
builtin/game/chat.lua

index b3edda0d2f9c406c20dff22bb46c5cfc713d2bf0..a71f4b3294a020f0b3f2c9f6684432fef3cb4bc9 100644 (file)
@@ -736,8 +736,9 @@ core.register_chatcommand("spawnentity", {
                        end
                end
                p.y = p.y + 1
-               core.add_entity(p, entityname)
-               return true, ("%q spawned."):format(entityname)
+               local obj = core.add_entity(p, entityname)
+               local msg = obj and "%q spawned." or "%q failed to spawn."
+               return true, msg:format(entityname)
        end,
 })