diff --git a/gamedata/scripts/callbacks_gameobject.script b/gamedata/scripts/callbacks_gameobject.script index 991541ad6..dd6dc9154 100644 --- a/gamedata/scripts/callbacks_gameobject.script +++ b/gamedata/scripts/callbacks_gameobject.script @@ -469,6 +469,15 @@ _G.CAI_Stalker__PathBuildFailCallback = function(npc) return flags.ret_value end +--Intercepts any console call (from scripts and handwritten alike) +--setting ret_value to true will consume console command +AddScriptCallback("on_before_console_execute") +_G.CConsole__BeforeExecuteCallback = function(str) + local flags = {ret_value = false} + SendScriptCallback("on_before_console_execute",str,flags) + return flags.ret_value +end + -- Improve NPCs pathfinding by reducing actual anomaly damage radius -- Works only when npc:get_enable_anomalies_pathfinding() == true or ai_die_in_anomalies cvar is 1 function is_outside_damage_radius(zone, obj) diff --git a/src/xrEngine/XR_IOConsole.cpp b/src/xrEngine/XR_IOConsole.cpp index acd099e8c..d82296e06 100644 --- a/src/xrEngine/XR_IOConsole.cpp +++ b/src/xrEngine/XR_IOConsole.cpp @@ -15,6 +15,12 @@ #include "../Include/xrRender/UIRender.h" +//VodoXleb:export console execute callback +#include "../../xrServerEntities/script_engine.h" +#include "../../xrGame/ai_space.h" +#include +//end of VodoXleb + //#include "securom_api.h" static float const UI_BASE_WIDTH = 1024.0f; @@ -39,6 +45,10 @@ static u32 const tips_scroll_pos_color = color_rgba(70, 70, 70, 240); ENGINE_API CConsole* Console = NULL; +//VodoXleb:export console execute callback +extern ENGINE_API BOOL g_bootComplete; +//--VodoXleb + extern char const* const ioc_prompt; char const* const ioc_prompt = ">>> "; @@ -584,6 +594,15 @@ void CConsole::ExecuteCommand(LPCSTR cmd_str, bool record_cmd) xr_strcpy(edt, str_size + 1, cmd_str); edt[str_size] = 0; + if (g_bootComplete) + { + ::luabind::functor funct; + if (ai().script_engine().functor("_G.CConsole__BeforeExecuteCallback", funct)) + { + if (funct(cmd_str)) + return; + } + } text_editor::remove_spaces(edt); if (edt[0] == 0) {