From c29cde17b310d721a5ff6b5a419b2fc246395215 Mon Sep 17 00:00:00 2001 From: main-thing <83129609+main-thing@users.noreply.github.com> Date: Thu, 11 Sep 2025 04:02:06 +0800 Subject: [PATCH] Add more functionality to Input() in VScript adds new functionality to Input() in vscript to - read the parameters of an input, via the input_value variable. - reassigning the activator and caller of the input --- src/game/server/baseentity.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/game/server/baseentity.cpp b/src/game/server/baseentity.cpp index 3462fd3700a..d5824d94d00 100644 --- a/src/game/server/baseentity.cpp +++ b/src/game/server/baseentity.cpp @@ -4430,10 +4430,15 @@ bool CBaseEntity::AcceptInput( const char *szInputName, CBaseEntity *pActivator, g_pScriptVM->SetValue( "activator", ( pActivator ) ? ScriptVariant_t( pActivator->GetScriptInstance() ) : SCRIPT_VARIANT_NULL ); g_pScriptVM->SetValue( "caller", ( pCaller ) ? ScriptVariant_t( pCaller->GetScriptInstance() ) : SCRIPT_VARIANT_NULL ); + g_pScriptVM->SetValue( "input_value", Value.String() ); if( CallScriptFunction( szScriptFunctionName, &functionReturn ) ) { bCallInputFunc = functionReturn; + // Allow reassignment of activator and caller of the input + IScriptVM *pVM = g_pScriptVM; + pVM->IfHas ( m_ScriptScope, "activator", [&](HSCRIPT value) { data.pActivator = ToEnt(value); } ); + pVM->IfHas ( m_ScriptScope, "caller", [&](HSCRIPT value) { data.pCaller = ToEnt(value); } ); } } @@ -4446,6 +4451,7 @@ bool CBaseEntity::AcceptInput( const char *szInputName, CBaseEntity *pActivator, { g_pScriptVM->ClearValue( "activator" ); g_pScriptVM->ClearValue( "caller" ); + g_pScriptVM->ClearValue( "input_value" ); } } else if ( dmap->dataDesc[i].flags & FTYPEDESC_KEY )