Scripting Language extensions via plugins

I posted this message above, just change 4.3 Preview to 4.3 release. That will get you a build of the engine with Lua support. I don’t think Robert has documented anything yet, other then this thread, so you have to dig in the source to find out what’s exported.

Thanks all for the answers. One other question, how are people debugging Lua within UE4? Any plans to support its debugging extensions with a slick but simple little IDE window that could be pulled up? That would be some killer feature right there.

Are you saying that the script work that’s been done is not in the official 4.3 release? If so, why would it be in the source code? I’m confused. Which source should be downloaded and rebuilt?

I’ve updated the earlier post below. The script plugin is in 4.3.0 Release source code, in the Engine/Plugins directory. I don’t think it’s been compiled into the 4.3.0 binary release. You have to compile it yourself.

  1. If you haven’t done so, you need to download the 4.3 0 Release source code from https://github.com/EpicGames/UnrealEngine/releases/tag/4.3.0-release

  2. Got to Lua: download and download the latest source (version 5.2.3)

  3. Remove it from the archive (use 7zip or similar archive program) and put it in \Engine\Plugins\Script\ScriptPlugin\Source\ScriptPlugin\ in a folder called lua-5.2.3 If you do this right, in you should have a path at \Engine\Plugins\Script\ScriptPlugin\Source\ScriptPlugin\lua-5.2.3\src that contains the .c and .h source files for lua.

  4. Run the GenerateProject.bat script that’s in the root folder of your engine source.

  5. Rebuild the engine.

  6. You should now have an engine that has Lua built-in and you can add scripts to blueprint objects in the editor.

It’s not that the plugin hasn’t been compiled into the binary release of the engine, it’s that it hasn’t been compiled with Lua enabled. Without Lua enabled the code generator plugin will still generate sample glue code that you can find under Engine/Intermediate/Build/Win64/Inc/Plugins/ScriptPlugin, this also addresses an earlier question about what is currently being exposed to Lua, there’s a generated .script.h in that directory for every class that’s exported.

Is it accurate to say that anything that Blueprint can access in UE4, Lua can access as well? Isn’t BP relying on UPROPERTY and UFUNCTION?

UPROPERTY, UFUNCTION and other Macros, decorations, are used to create code reflection. So whatever is exposed to code reflection should be accessible, for any other system, which can take advantage of it.

I’m getting this link error: Error 1 error LNK2005: main already defined in lua.c.obj UnrealEngine-4.3\Engine\Intermediate\ProjectFiles\luac.c.obj

Obviously there’s a main already defined in the editor target. Shouldn’t the main in lua be commented out since we aren’t using it? Is there any patch needed here?

Quoting the relevant bit from Robert’s first post in this thread:

Very creative.Thank’s for this.

I’m experiencing two issues here:

I successfully compiled the engine and editor with Lua, however, I don’t see any ScriptActor or ScriptComponents in the editor to create.

The Plugin appears to be making the game run in simulator mode, even when simulation isn’t turned on. I know this because I have some C++ code that puts my actors in certain locations and it started doing that when I opened the project despite not running the simulator.

Edit:

I think I may have found a script component, I attached a script to it though, and I’m not really sure how to be able to see any of these variables in the editor, or blueprints as they don’t show up in either, though I know the integration is working because I do get the print statements in my log. Also, I only see a ‘Script Test Actor’, not a Script Actor.

Just drag and drop a lua script (a file with .lua extension) into the content browser. It will ask you for a base class for it (just like Blueprints), you can pick any class you want. The only special class is ScriptComponent that should be used for creating Lua components but only because it’s the only way you can have a Tick function for a component in Lua.

I’ll try to write up some docs soon.

And to answer one of the previous questions: Lua plugin is still in ‘early access’ phase, so we’re committed to developing it but since development is not yet complete, we don’t fully support it. However, I’d say we have the experimental stage behind us and we’re going to be adding workflow improvements and new features from now on.

Is this only in the latest preview and not 4.3? That may be my issue, as I noticed the latest preview has more code commits. When I drag it in at 4.3 it just becomes an asset with no option to choose a base class.

Also, I don’t know how hard this would be , but it would be awesome if we had a simple text edit within the editor to make hot fixes to the Lua scripts. It doesn’t need syntax highlighting or anything, just a way to make quick changes or add prints for debugging. Currently the work flow is a little annoying for a scripting language, you need to edit outside of the editor, then reimport, which isn’t too bad, but it could be even better!

It’s not in the pre-built binaries, but if you compile the engine with Lua source code copied to the plugin folder as described in one of the previous posts, it should work.

Built-in editor is something we’ve been discussing recently.

Thats great to hear. I compiled the 4.3 engine on github, ill try again.

Built in editor with syntax highlighting and debugger would be killer. Is it votable in the roadmap site?

Using 4.3 release on github, if I try to import I don’t get any prompt to parent, and if I right click the ‘Create Blueprint using…’ is greyed out. Its a .lua file type.

Ah, Sorry! Just looked at the dates of my check-ins. It’s in Master branch only for now. It missed the 4.3 branch date by a day or two :frowning: I guess you need to wait for 4.4 if you don’t want to get the master branch.

Not yet, but you can vote on ‘Script Plugin Improvements’. If that gets more votes, everything related will too.