From 7d1952126dcaee4ba863cf35066671fd4d23ef95 Mon Sep 17 00:00:00 2001 From: Petr Ohlidal Date: Sat, 4 Dec 2021 18:26:54 +0100 Subject: [PATCH] Console command 'as': print messages _after_ code. --- source/main/system/ConsoleCmd.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/main/system/ConsoleCmd.cpp b/source/main/system/ConsoleCmd.cpp index 9ce8e7bffb..da6fd9f0bb 100644 --- a/source/main/system/ConsoleCmd.cpp +++ b/source/main/system/ConsoleCmd.cpp @@ -320,19 +320,25 @@ class AsCmd: public ConsoleCmd // we want to notify any running scripts that we might change something (prevent cheating) App::GetScriptEngine()->triggerEvent(SE_ANGELSCRIPT_MANIPULATIONS); - Str<1000> code; // Re-compose the code snippet + // Re-compose the code snippet + Str<1000> code; for (int i = 1; i < args.size(); ++i) { code << " " << args[i]; } - App::GetScriptEngine()->executeString(code.ToCStr()); + + // Echo the code back to console user. reply_type = Console::CONSOLE_SYSTEM_REPLY; reply << " >>> " << code.ToCStr(); + App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, reply_type, reply.ToCStr()); + + // Run the code - will output script messages/AngelScript errors. + App::GetScriptEngine()->executeString(code.ToCStr()); #else reply_type = Console::CONSOLE_SYSTEM_ERROR; reply << _L("Scripting disabled in this build"); -#endif App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, reply_type, reply.ToCStr()); +#endif } };