ncsoft / Unreal.js

Unreal.js: Javascript runtime built for UnrealEngine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] Use this as ingame scripting?

Uniphix opened this issue · comments

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?

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

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

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.

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

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.

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?

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

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

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