-
Clone the project into your Plugins directory.
-
Download ThirdParty.zip and unzip it into the Plugins directory.
-
Add this Flathead to the PrivateDependencyModuleNames list.
PrivateDependencyModuleNames.Add("Flathead");
-
Overwrite the base module, hooking into the StartupModule method.
class FMyJSSampleModule : public FDefaultGameModuleImpl { virtual void StartupModule() OVERRIDE; }; void FMyJSSampleModule::StartupModule() { if (IFlathead::IsAvailable()) { IFlathead::Get().LoadGameScript("GameInit.js"); } }
-
Add your script file to the /Scripts directory of your project.
game.log("Game Initialization"); Object.addEventListener("game.tick", function (ev) { game.log("tick.", ev.deltaTime); });
-
Expose your types to JS
void AFH_FlyingPawn::Expose() { if (!IFlathead::IsAvailable()) return; IFlathead &ref = IFlathead::Get(); HandleScope handle_scope(ref.GetIsolate()); Local<Context> context = ref.GetGlobalContext(); Context::Scope ContextScope(context); Local<Object> Bob = ref.Expose(this, TEXT("Bob")); Bob->Set(String::NewFromUtf8(ref.GetIsolate(), "value", String::kInternalizedString), Number::New(ref.GetIsolate(), 42)); Local<String> key = String::NewFromUtf8(ref.GetIsolate(), "test", String::kInternalizedString); ref.LoadGameScript("BobTest.js"); }
-
Enjoy!
Please consult the Wiki for further documentation. If you run into any issues, please file a ticket in the GH Tracker.
- Flying Game: https://github.com/BobGneu/UE4FlyingGame
Exposing Functions is currently not working, but may be addressed with updating to a later build of V8. You can contribute to the discussion on this topic here: https://groups.google.com/forum/#!topic/v8-users/cYkuljdJEJ8
If you have any Questions, Comments, Bug reports or feature requests for this plugin, or you wish to contact me you can and should email me - bob@gneu.org
Alternatively, you can join me in #gneu on irc.freenode.net or irc.gamesurge.net