Scripting Language extensions via plugins

@, now with latest “Fixing UHT not finding ScriptGeneratorPlugin” commit, ScriptPlugin builds fine. But when I tried to enable Paper2D binding by adding “+ScriptSupportedModules=Paper2D”, there’s error:


1>e:\dev\unreal\src\47x\Engine\Plugins\ScriptPlugin\Source\ScriptPlugin\../../../2D/Paper2D/Source/Paper2D/Public/MaterialExpressionSpriteTextureSampler.h(6): fatal error C1083: Cannot open include file: 'MaterialExpressionSpriteTextureSampler.generated.h': No such file or directory
1>  -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: e:\dev\unreal\src\47x\Engine\Plugins\ScriptPlugin\Binaries\Win64\UE4Editor-ScriptPlugin.pdb


In Visual Stduio project, verify “MaterialExpressionSpriteTextureSampler.generated.h” is generated in “e:\dev\unreal\src\48x\Engine\Plugins\2D\Paper2D\Intermediate\Build\Win64\UE4Editor\Inc\Paper2D\MaterialExpressionSpriteTextureSampler.generated.h”

To be honest, I’ve never tried it with a plugin, looks like a bug. I’m going to look into it next week.

Robert, I fixed that error by adding “Paper2D” into PublicDependencyModuleNames of ScriptPlugin.Build.cs

I Seem to be missing something, I’ve added the script component to an actor but can’t seem to access the variables in the lua script. Based on damody steps i should see a Category under details with the name of the script and any public properties, but i’m not seeing that, the script component seems to have a different icon as well. Any Ideas? also is there no indication as to what script file is attached to the script component?

Hi , in 4.7, the name of ScriptComponent is now ScriptPluginComponent. When you import Lua script into Unreal, it will ask you to choose a parent class, make sure you select ScriptPluginComponent.

Ahh thanks, that would probably be it. What is ScriptComponent then?

@anonymous_user_b5a3220c, judge from the icon in your screenshot, I think you’re using the buildin “Blueprint Script Component” which is not the same as “Lua” Script Component came from Lua Script Plugin.

@, is there any good approach to bind/export UStructs automatically? (As there’s only limited UStructs supported hardcoded in ScriptPlugin, so any function signature using UStructs not supported will not be binded.)

Got following building error when binding UMG module:


1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Animation/UMGSequencePlayer.h(17): error C2061: syntax error : identifier 'UUserWidget'
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Animation/UMGSequencePlayer.h(23): error C2653: 'EUMGSequencePlayMode' : is not a class or namespace name
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Animation/UMGSequencePlayer.h(23): error C2061: syntax error : identifier 'Type'
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Animation/UMGSequencePlayer.h(79): error C2653: 'EUMGSequencePlayMode' : is not a class or namespace name
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Animation/UMGSequencePlayer.h(79): error C2146: syntax error : missing ';' before identifier 'PlayMode'
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Animation/UMGSequencePlayer.h(79): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Blueprint/WidgetBlueprintLibrary.h(16): error C2079: 'Z_Param_Out_ContextTemp' uses undefined struct 'FPaintContext'
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Components/ScaleBoxSlot.h(45): error C2065: 'SScaleBox' : undeclared identifier
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Components/ScaleBoxSlot.h(45): error C2923: 'TSharedRef' : 'SScaleBox' is not a valid template type argument for parameter 'ObjectType'
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Components/ScaleBoxSlot.h(52): error C2065: 'SScaleBox' : undeclared identifier
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Components/ScaleBoxSlot.h(52): error C2923: 'TSharedPtr' : 'SScaleBox' is not a valid template type argument for parameter 'ObjectType'
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Components/ScaleBox.h(24): error C2653: 'EStretchDirection' : is not a class or namespace name
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Components/ScaleBox.h(24): error C2065: 'Type' : undeclared identifier
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Components/ScaleBox.h(24): error C2923: 'TEnumAsByte' : 'Type' is not a valid template type argument for parameter 'TEnum'
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Components/ScaleBox.h(28): error C2653: 'EStretch' : is not a class or namespace name
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Components/ScaleBox.h(28): error C2065: 'Type' : undeclared identifier
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Components/ScaleBox.h(28): error C2923: 'TEnumAsByte' : 'Type' is not a valid template type argument for parameter 'TEnum'
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Components/ScaleBox.h(62): error C2065: 'SScaleBox' : undeclared identifier
1>e:\dev\unreal\src\48x\Engine\Source\Runtime\Core\Public\../../../../Source/Runtime/UMG/Public/Components/ScaleBox.h(62): error C2923: 'TSharedPtr' : 'SScaleBox' is not a valid template type argument for parameter 'ObjectType'

Has anyone got this issue?

and Robert, I have made great progress working on a python scripting integration using boost::python to generate bindings.

I just want to make sure I understand how the Scripting examples work so that I can figure out the best way to distribute my own plugin when the time comes.

ScriptGeneratorPlugin is a UHT plugin. When UHT is configured to load ScriptGeneratorPlugin, a bunch of files are generated containing the glue that is the headers for the actual classes + the actual bindings.
ScriptPlugin is what actually includes the “GeneratedScriptHeaders.inc” or whatever, and also contains the pieces that expose the bindings to the engine, in ScriptEditorPlugin

So, the easy way to get started on this is to add a new language to these existing plugins, but that makes distribution and ownership complicated, as you are modifying a included plugin.
Ideally, I’d like to move my code into “MyScriptGeneratorPlugin” and “MyScriptPlugin”, but I have a few questions about this.

  1. Do ScriptGenerator plugins HAVE to be part of the entire Source/Engine structure in order for UHT to load them?
  2. How exactly does UHT find ScriptGeneratorPlugin?
  3. If I want to rapidly interate in terms of generating the bindings repeatedly, how can I run UHT without triggering an engine build+link? Right now I am deleting the headers generated and then doing it again but it still takes a long time and links the EXE’s at the end as if i changed a core engine file.

The goal is for me to have a completely seperate directory structure and repo for just my python bindings, so I can easily have ownership of the code, distribute it, and keep it in a public repo without breaking any licenses

Hi Danatarion,

Try to answer your question with my limited knowledge on this subject: (anyone spots any error please jump in and correct me)

3. If I want to rapidly interate in terms of generating the bindings repeatedly, how can I run UHT without triggering an engine build+link? Right now I am deleting the headers generated and then doing it again but it still takes a long time and links the EXE’s at the end as if i changed a core engine file.

You can run UnrealHeaderTool as commandlien too to generate script binding. e.g. this is the commandline I use:


UnrealHeaderTool.exe e:/devgit/UnrealTournament/UnrealTournament/UnrealTournament.uproject e:\dev\unreal\git\UnrealTournament\UnrealTournament\Intermediate\Build\Win64\UnrealTournamentEditor\Development\UnrealHeaderTool.manifest

2. How exactly does UHT find ScriptGeneratorPlugin?

First, you let UHT know your plugin in UnrealHeaderTool.Target.cs:



public UnrealHeaderToolTarget(TargetInfo Target)
{
	Type = TargetType.Program;
	AdditionalPlugins.Add("ScriptGeneratorPlugin");
	AdditionalPlugins.Add("YourScriptGenerator");
}


and enable it in UnrealHeaderTool config file: (Engine\Programs\UnrealHeaderTool\Config\DefaultEngine.ini)


[Plugins]
+ProgramEnabledPlugins="ScriptGeneratorPlugin"
+ProgramEnabledPlugins="YourScriptGenerator"


Then in your script generator module, you register “ScriptGenerator” module feature:


void FYourScriptGeneratorPlugin::StartupModule()
 {		 {
	IModularFeatures::Get().RegisterModularFeature(TEXT("ScriptGenerator"), this);
 }	

Now UHT know your script generator plugin is enabled and ready to be use as “ScriptGenerator”

1. Do ScriptGenerator plugins HAVE to be part of the entire Source/Engine structure in order for UHT to load them?

I haven’t try that but I see no reason it wont work.

Thanks.
I don’t like how this stuff seems to be “magic” but if we put all this information info a page on the Unreal wiki then it won’t be!

I really feel like scripting support is an important part of the engine’s ecosystem, as Blueprints require so much new learning for someone to use, I’d rather use a scripting language, abstract as much of the Unrealism’s and keep them behind the scenes, and let other team members work primarily in the scripting language.

To answer my own “binding UMG module” question, it’s easy to fix, just make sure:

  1. add “UMG” to the PublicDependencyModuleNames of your script runtime’s Build.cs file
  2. add "#include "Runtime/UMG/Private/UMGPrivatePCH.h"to your script runtime PrivatePCH.h file

Error C1083: Cannot open include file: ‘GeneratedScriptLibraries.inl’: No such file or directory - Engine\Plugins\ScriptPlugin\Source\ScriptPlugin\Private\ScriptPlugin.cpp (Line 20, Column 1)

I’ve tried multiple fixes here in order to get Lua Implementation to work. I’ve added Lua-5.3.0 in the Lua Folder, and built successfully for Release Win32 and x64.

Changed


#if 0
#include "GeneratedScriptLibraries.inl"
#endif

to


#if 1
#include "GeneratedScriptLibraries.inl"
#endif

in ScriptPlugin.cpp!

Changed


"EnabledByDefault" : false,

to


"EnabledByDefault" : true,

in ScriptGeneratorPlugin.uplugin

Tried with both


"Category" : "Examples",

and


"Category" : "UnrealHeaderTool.Code Generator.Generic",

in ScriptGeneratorPlugin.uplugin

But nothing… I just want Lua!!! D:

Plugin Update

[The video is a work-in-progress - though we hope it gets some of the main concepts across.]

is a text-based programming language for creating performance-critical, real-time gameplay and it now is available as a free turn-key plugin for UE4.

is completely unlike Lua. :smiley:

Our plugin is originally based on the work referenced by this thread done by Manuszewski and other contributors.

It has been a while since we’ve given an update to this thread and we’ve progressed significantly.

Now that code plugins are soon coming to the Unreal Marketplace, we’ve started the submission process for .

More Info and Get the Latest Release

  • If you are interested in more information and updates, check out the directly or use the UE4 thread.
  • Get the latest release of the UE4 plugin once you sign up for the beta.
  • You can also see the , , and (Standard version is free, a huge enhancement to the workflow of any UE4 developer and it may be all you will ever need).

@CTxCB, It seems to me you have done everything right, but the missing of ‘GeneratedScriptLibraries.inl’ indicated that the “ScriptGeneratorPlugin” is not actually running.

Can you double check that Lua.lib is in correct folder?


Engine\Plugins\ScriptPlugin\Source\Lua\Lib\Win64\Release\Lua.lib

And tried to rebuild UnrealHeaderTool project, then build engine again, you should be able to find ‘GeneratedScriptLibraries.inl’ in:


Engine\Plugins\ScriptPlugin\Intermediate\Build\Win64\UE4Editor\Inc\ScriptPlugin\GeneratedScriptLibraries.inl

hi,guys who try build this plugin use in mobile platform I mean like android
and how do it, really want konw,thanks

@cwytian, I haven’t build it for mobile but would assume it’s about the same as for PC. That been said, it would be wiser to treat ScriptPlugin more as a learning/example project rather than production-ready plugin.

I would recommend you take a look into the plugin mentioned in previous post if you’re looking for scripting solution, it’s still in close (or open?) beta, but will be available in Marketplace soon if I understand correctly.

Yes we are working on getting the plugin submitted to the Marketplace as we speak. There are still a few aspects of code plugins that need to be ironed out - but hopefully very soon.

Also though we have only been supporting Windows for the beta so far - we almost have it working for iOS. Just a few more tweaks and tests.

Other platforms will soon follow. has already been used to create games that shipped on Windows, Xbox 360/One, PlayStation 3/4.

Did anybody managed to make lua work on OS X ? The readme (in UnrealEngine/4.8/Engine/Plugins/ScriptPlugin/Source/Lua) says to open and build “Engine/Plugins/ScriptPlugin/Source/Lua/Lua.sln” in Visual Studio but how can I make an XCode project?

Is there a blog post on this script plugin now?