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

[Question] Use this as ingame scripting? #333

Open
Uniphix opened this issue Apr 19, 2023 · 9 comments
Open

[Question] Use this as ingame scripting? #333

Uniphix opened this issue Apr 19, 2023 · 9 comments

Comments

@Uniphix
Copy link

Uniphix commented Apr 19, 2023

Could this be used as ingame scripting? Is there a way to restrict and expose certain things that can only be done say on a ingame computer?

Basically I want to be able to design an ingame computer that can run multiple applications but limited to game functionality as I would be concerned for security as this would be used in a MP world. Don't want unwanted functions that could hurt the players actual computer as the entire UE Api is excused from my understanding?

@Uniphix Uniphix changed the title Use this as ingame scripting? [Question] Use this as ingame scripting? Apr 19, 2023
@getnamo
Copy link

getnamo commented Apr 20, 2023

You can runtime reload a JavaScript file allowing you to write scripts and execute them at game time even in a packaged game (see #46 (comment)).

Regarding safety, by default the whole UE api gets exposed, but if you go lower in the API you can control what gets exposed. In a fork of this plugin I made a new js component type using the lower api that can control this exposure (https://github.com/getnamo/Unrealjs#javascriptinstance and see #259 (comment) for api notes).

@Uniphix
Copy link
Author

Uniphix commented Apr 20, 2023

Thanks for the reply! So basically I would just use something like what you suggested and only expose what I want?

@getnamo
Copy link

getnamo commented Apr 20, 2023

It hasn't been tested heavily for robustness of safety for partial expose (e.g. root JavaScript component only), but in theory that's how it should work. Also if you expose no unreal objects, it will just be a vanilla script with no access to anything outside its scope.

Edit: this appears to be the c++ code that handles the common expose api: https://github.com/getnamo/UnrealJs/blob/master/Source/V8/Private/JavascriptInstanceComponent.cpp#L86

Looks like 'Context' or 'JsOwner' is likely the one you want to try first. This should only expose e.g. the functions on the owning actor which you can control.

@Uniphix
Copy link
Author

Uniphix commented Apr 20, 2023

Perfect thanks! Yeah I don't want to expose any of the UE stuff and if I do it'll be a wrapper to expose only what needed...

@Uniphix
Copy link
Author

Uniphix commented Apr 20, 2023

Do you have a version that works for 4.27.2? For some reason I have spent over 5 hours trying to get the plugin built and keep getting failures.

@Uniphix
Copy link
Author

Uniphix commented Apr 20, 2023

I tried to use the build the plugin steps but it just doesn't want to do it's work everytime I try to build from the modules it fails, and manual compiling works but still prompt to ask. Am I missing something? Do I need to add anything else?

@getnamo
Copy link

getnamo commented Apr 20, 2023

If you cloned from git you need the V8 third party dependencies, or just download a release which should have them.

@Uniphix
Copy link
Author

Uniphix commented Apr 20, 2023

Yeah but so far I am finding anything that works with 4.27

@Uniphix
Copy link
Author

Uniphix commented Apr 21, 2023

@getnamo thanks for the guidance, I was able to do several things, I basically took your copy of your branch, and then basically went through all the changes by comparing against a specific branch of UnrealJS-core that was closest to 4.27 (4.26 is what I used) and then found what changed between UE4.26 to 4.27 and what changed between 4.27 to 5.1 and thus got it all compiled!

For those who may run into situations, if it doesn't build the modules, it's probably because there are compiling errors when using a specific version, in my case I was using 5.1 and was trying to build it against 4.27 (IT DID NOT LIKE THAT LOL). There was quite a bit of changes such as FEditorStyle was changed to FAppStyle in 5.1.

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

No branches or pull requests

2 participants