Scripting Language extensions via plugins

I’ve gotten a step further:

Adding this to ScriptPlugin build file:

                if (Target.Platform == UnrealTargetPlatform.Mac || Target.Platform == UnrealTargetPlatform.IOS)
                {
                    Definitions.Add("LUA_USE_POSIX=1=1");
              
                }

Gets a successful compile, still testing to see if there are any other issues caused by this.

I hit a road block…if I import a lua script, choose a parent class then drag it into the level and try to save, I get this error:

Warning Can’t save …/…/…/XXXX/Content/Model.umap: Graph is linked to external private object ScriptContextComponent /Game/Scripts/BattlePlayer.Default__BattlePlayer_C:ScriptContext (unknown property ref)

Hey guys, I’ve read through this thread but I have a very newbie question for you - sorry in advance. So I want to do some scripting in UE4 and I’ve followed the steps to integrate this work, but what do I actually DO to use this stuff? Do I write C++ code to read and parse lua keywords? Where do I write the Lua? Is this a blueprint component I drag in?

You see my point - I really have no idea of the workflow at all. Where do I start?

(don’t worry, I can code so I’m not a TOTAL newbie - never scripted though)

Still haven’t found a way around this yet, I’ve tried creating new projects, etc. Is anyone else having problems with 4.4.1 scripting?

Here is the link to the q & a I made for it:

Hi guys - is there a documentation or tutorial page for this stuff yet? Thanks!

Ever since this has been incorporated into UE4, I get the following error when trying to clean or build my UE4 project (from GitHub). 4.4.1.


Anyone getting similar? Why would it try to build this file?

EDIT: All of the files that come from GitHub and the dependencies are checked in to our Perforce server, as they shouldn’t change. But the above access issue means that a fresh UE4 build is trying to change a file that comes with it.

Is this feature still developed? The card has been archived, last message from Robert is dated end of July and on github doesn’t seems to be much activity (https://github.com/EpicGames/UnrealEngine/commits/master/Engine/Plugins/Script). There are further plans on this feature?

Not an answer as to whether there is any future work on this Lua plug-in - though there seems to be some additional code that made as recently as 5 days ago in the “master” branch. It didn’t make it for version 4.4.2 though it should be in for 4.5.

will still be added as a full text scripting plug-in which builds on this scripting plug-in example. You can see more info on its post at -

Hey guys, sorry I haven’t been visiting the forums too often lately, will try to make up for that!

A few words on the plans for the plugin: we got to a point where we’d have to commit additional resources to continue implementing Lua integration, with sample content etc. The problem is we don’t really have those resources at the moment. Another problem is that my knowledge of how to use Lua from the gameplay perspective is rather limited so we’d have to bring someone who could help but we really didn’t have anyone like that (well, at least no one who’d be available to commit to it!). We also started considering other alternatives to Lua but haven’t reached any decisions yet, mostly because of the same reasons as I just mentioned.

In the meantime we decided that for now we should focus on our ‘default’ workflow, which is C++. So I’m currently mostly focused on Hot-Reload improvements.

I’m not saying we’re done completely with any improvements and development though! We just need time to look at all the available options and make the right choice!

I’ll try to pay more attention to the forums though and try to provide better support for other integration use the plugin! Sorry for being really poor at that!

Hi Robert and thank you very much for your reply!

I still believe that the “scripting languages” feature would be a great boost for small teams with coding experience, I appreciated a lot what you did and I would like to see it improved further to a “production plugin”. While I think Lua is the perfect choice for a first integration, I think the most important point here is to have a good bridge to bind “scripting languages” to the reflected informations available in UE4.

It seems that here there are people that would like to invest time and resources to test and improve this feature, and would be great if Epic would leave at least one resource on this task!

Sorry for this small “exhortation”, but I really think that productivity (at least the one of my team!) would benefit a lot of this feature :wink:

Sure , I’ll keep supporting it for sure, so no worries. We just don’t want to commit to any new features and dates at this point.

I also wanted to give everyone a heads up that I’ll be submitting some changes tomorrow morning that should fix the issue with not being able to compile with Lua in the Master branch. I also moved the ScriptGeneratorPlugin directly to Plugins folder and merged ScriptPlugin and ScriptEditorPlugin into one plugin (with two separate modules - runtime and editor).

Robert,

Does UHT run a ScriptGeneratorPlugin from the Game Plugin folder? I tried it and had some issues, but didn’t follow up. I’m working from the Engine/Plugin and that works fine for now.

Also, if it’s an easy patch, can the editor track the file extension and pass it to the script plugin? I want to support multiple languages and tracking the extension is the easiest way to direct things the right way. If it can’t make it this time, I’ll make the change myself, but if it makes it, cool.

Thanks! :slight_smile:

Yeah, it doesn’t appear to be easy to use the script plugin from within a game.

Looking at the code, it seems you need to interface with the Unreal Header Tool to generate files at build time. I’ve been trying to figure out how to get the build tool to recognize my game project, but it does not seem to want to generate from my game project.

I’m going to keep on digging!

You can control which modules are wrapped via the ScriptSupportedModules setting in the Plugins section of the Engine.ini for Unreal Header Tool, the defaults can be found in Engine\Programs\UnrealHeaderTool\Config\DefaultEngine.ini. As you’ll see only the CoreUObject, Engine, and ScriptPlugin modules will be wrapped by default. If you’d like to add additional modules for wrapping you can either specify them in the aforementioned DefaultEngine.ini, or in Engine\Programs\UnrealHeaderTool\Saved\Config<Platform>\Engine.ini. Admittedly I haven’t tried wrapping game modules myself yet, so I’m not 100% this will work.

Looking into it, in PluginManager.cpp lines 228 -> 237.



#if (WITH_ENGINE && !IS_PROGRAM) || WITH_PLUGIN_SUPPORT
		// Find "built-in" plugins.  That is, plugins situated right within the Engine directory.
		Local::FindPluginsIn( FPaths::EnginePluginsDir(), EPluginLoadedFrom::Engine, Plugins );

		// Find plugins in the game project directory (<MyGameProject>/Plugins)
		if( FApp::HasGameName() )
		{
			Local::FindPluginsIn( FPaths::GamePluginsDir(), EPluginLoadedFrom::GameProject, Plugins );
		}
#endif		// (WITH_ENGINE && !IS_PROGRAM) || WITH_PLUGIN_SUPPORT


Since the UHT is building the include scripts during the execution of UnrealHeaderTool (MyGameProject = UnrealBuildTool) instead of the execution of the build of the Game, it seems it cannot find game plugin directory during build.

There seems to be two options at this point:

  1. Build something like the UHT for their game project and inject it into the tool chain
  2. Move any plugins into the engine plugin folder instead of keeping it in the game folder.

Both of these options aren’t ideal, but the second one at least follows the plugin pattern they are using.

Unless I’m totally off and someone at Epic can correct me. That would certainly make my day :smiley:

That explains why I’ve been struggling so much with even basic plugins! The moment I add code, the whole thing falls apart.

Does this allow for mod-esque run-time script loading? I’d love to be able to ship editable scripts with my app and I’m not sure what the best way to do that is right now.

Is there any documentaion or a bigger sample code?

I want to create actors which are controlled over lua scripts.

So far I compiled the engine with lua integration and got a script loaded in the game.


print("Lua in UE4!")
TickCounter = 0
Mesh = UE.LoadObject(StaticMesh.Class(), "CUBE", "/Engine/EngineMeshes/ParticleCube.ParticleCube");
function Tick()
	TickCounter = TickCounter + 1
end

function Destroy()
	print("Destroy Lua script")
 	StaticMesh.Destroy(Mesh);
end

This script starts and works. But I don’t see the loaded mesh. How can I interact with the mesh? (where is the documentation for the available methodes?)

Would be great if someone could help me get started :wink:

Best regards,
Michael