UEVR icon indicating copy to clipboard operation
UEVR copied to clipboard

Add ability to execute console commands from file

Open keton opened this issue 1 year ago • 12 comments

Certain game profiles need CVars from outside the scope provided by UEVR. Editing engine.ini makes profile sharing more complicated.

This changeset adds ability to execute commands from user_script.txt located inside game profile folder. Syntax and effects are the same as commands were entered in console. Namely one command per line, space separated arguments.

This allows flexible customization bundled in profiles that need it.

Example use case is Abzu where adding snippet r.WaterSurfaceReflections 0 to user_script.txt disables distracting visual effects.

EDIT: Revised version uses UEngine::Exec() which allows any command that would work in UE native console.

It also supports comments so following syntax is correct:

# this is a full line comment
; this as well
r.WaterSurfaceReflections 0 # and this is inline comment
stat fps ; this as well

keton avatar Jan 07 '24 22:01 keton

I like this change a lot

mark-mon avatar Jan 20 '24 11:01 mark-mon

Sorry i am newbie... how to do this change ?

MatLePirat avatar Jan 23 '24 21:01 MatLePirat

If you're a noobie you'll need to wait for this PR to be approved and then release with the change to be made. If you're willing to learn how to compile software from source you can pull my branch and build your own .dlls

keton avatar Jan 23 '24 22:01 keton

Thank you so much for your answer, and for your work generaly. My problem is in abzu, i dont know in wich file i should write the command "r.WaterSurfaceReflections 0" i try in some files but it dont work for now... i must change it in console each time i launch the game :( i hope your add will come soon 0:)

MatLePirat avatar Jan 24 '24 13:01 MatLePirat

Without this change you need to find game profile directory which should be %LOCALAPPDATA%\AbzuGame\Saved\Config\WindowsNoEditor\. There will be a bunch of .ini files and you should either create or edit Engine.ini. Then add:

[SystemSettings]
r.WaterSurfaceReflections=0

When this change lands you'd create user_script.txt in UEVR profile and put r.WaterSurfaceReflections 0 there instead. And then profile can be shared complete with engine variable changes :)

keton avatar Jan 24 '24 13:01 keton

Should look into using UEngine::exec now, it is possibly more stable, though would have to examine its stability across games as it is new

It also has access to the "exec" functions that are completely unseen by the console manager (I think anyways? I'd have to double check whether this can still run commands like "fly")

praydog avatar Jan 26 '24 18:01 praydog

@praydog Sure, I can do that. It will be also smaller, more localized change, easier to merge with everything else.

But from my playing around with exec(L"show fps") as a part of #170 I've noticed game freezes for quite a few seconds when exec() is first called. Is that normal?

keton avatar Jan 26 '24 18:01 keton

Yes it's part of the scanning process. It can be optimized more.

praydog avatar Jan 26 '24 18:01 praydog

I'll try then. In case loading list of commands takes a long time we can revert to current implementation. For some games I needed 30 or so parameters. I hope it does not need to scan like this for each one.

keton avatar Jan 26 '24 18:01 keton

No, it only needs to do it once

praydog avatar Jan 26 '24 18:01 praydog

@praydog I've just noticed that UGameEngine::exec() returns void. It would be useful to know if engine recognized and executed the command. Like in UE4SS Console Unlocker when it says 'unknown command' on failure. Is something like that possible in UEVR?

Anyhow new version of this patch using exec() is written. Now I'll do some testing and if that works update this pr. I've also added option to handle simple line comments with # this is the comment syntax.

keton avatar Jan 27 '24 09:01 keton

Quick test report.

Result: exec() works with my patch. On some occasions there's a few seconds freeze when it loads.

Platform: 7900x, 4090, Quest 3, Virtual Desktop, VDXR Tested games: image Exceptions: Titan station, Call of Cthulhu and Aven Colony

UEVR was injected on 30s delay. Some of those games will crash without it but that was also the case before.

keton avatar Jan 27 '24 16:01 keton