UE1 - UT Override console command while preserving behavior

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

G-Flex

New Member
Oct 25, 2012
16
0
0
Let's say I want something to happen when a console command/exec function is called, but also want the original code to be executed.

The former is easy: I can override it by placing my own exec function in the player class. However, how do I then cause it to invoke the original command I'm overwriting?

For example, say I want to override ToggleFullscreen, which is an existing console command but not available for editing in any of the script files. I could do this:
exec function ToggleFullscreen()
{
// do stuff
}
... but then it wouldn't actually toggle fullscreen. Is there a way to override the function but then invoke the original?
 

meowcat

take a chance
Jun 7, 2001
803
3
18
For some functions that are normally native console functions, you could create a uscript exec function of the same name (I don't know if this would cause conflicts, you would have to test this out), and then use the 'ConsoleCommand' function to call the console version. See this function is actor.uc for both the Unreal series and in DeusEx
Code:
// Execute a console command in the context of the current level and game engine.
native function string ConsoleCommand( string Command );

However if I recall correctly calling uscript exec functions in the console *may* require the prefix "exec " before them, in which case overriding the native console commands may be a no-go...
 

BashBox

Just a casualty of unreal
Feb 26, 2011
18
0
0
hijack the users keypress to preform your desired function.

just set the players f12 key to f12=togglefullscreen | mynewfunction

not sure how usefull this is in your case , as the user may use the console, of mazimine button , or the windows key etc to avoid calling your funtion.

also i had the idea if you knew what class the native code was defined in , you could try and be very specific and call FE "console.togglefullscreen();" but i figure that would never work anyway
 
Last edited:

[]KAOS[]Casey

227 dev
May 17, 2009
28
0
0
California
www.klankaos.com
ConsoleCommand is not final. Let's use this to our advantage.

Code:
function string ConsoleCommand( coerce string S )
{
 if (S ~= "ToggleFullScreen")
CustomToggleFullScreenCrap();
return super.ConsoleCommand(S);
}

Done.

ps: you may want to use instr(caps(s),caps("togglefullscreen")) != -1 for the check in case there's a space or something.
 
Last edited:

G-Flex

New Member
Oct 25, 2012
16
0
0
Yeah, I figured out that overriding the ConsoleCommand function (in both the player and console classes) would suffice.

Of course, that doesn't intercept alt-enter for toggling fullscreen, but it doesn't matter much because I found a better solution to what I was doing.