Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to execute console commands from file #96

Merged
merged 1 commit into from
Mar 3, 2024

Conversation

keton
Copy link
Contributor

@keton keton commented Jan 7, 2024

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 keton force-pushed the feat/execute_console_script_file branch from c272b8c to 8f8c6f1 Compare January 12, 2024 11:54
@mark-mon
Copy link
Contributor

I like this change a lot

@MatLePirat
Copy link

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

@keton
Copy link
Contributor Author

keton commented Jan 23, 2024

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

@MatLePirat
Copy link

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:)

@keton
Copy link
Contributor Author

keton commented Jan 24, 2024

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 keton force-pushed the feat/execute_console_script_file branch from 8f8c6f1 to 21330ea Compare January 26, 2024 11:23
@praydog
Copy link
Owner

praydog commented Jan 26, 2024

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")

@keton
Copy link
Contributor Author

keton commented Jan 26, 2024

@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?

@praydog
Copy link
Owner

praydog commented Jan 26, 2024

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

@keton
Copy link
Contributor Author

keton commented Jan 26, 2024

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.

@praydog
Copy link
Owner

praydog commented Jan 26, 2024

No, it only needs to do it once

@keton
Copy link
Contributor Author

keton commented Jan 27, 2024

@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.

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.

This allows flexible customization bundled in profiles that need it.

Syntax and effects are the same as commands were entered in native console.
Namely one command per line, space separated arguments.

Comments are supported in form of whole line comments starting with '#'
or ';'. Additionally inline comments are supported in form of
`command param # comment`

Example is Abzu where addding snippet `r.WaterSurfaceReflections 0` to
`user_script.txt` disables distracting visual effects.
@keton keton force-pushed the feat/execute_console_script_file branch from 21330ea to 6efe0d3 Compare January 27, 2024 11:09
@keton
Copy link
Contributor Author

keton commented Jan 27, 2024

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.

@praydog praydog merged commit 03237f9 into praydog:master Mar 3, 2024
@keton keton deleted the feat/execute_console_script_file branch March 4, 2024 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants