Scripting Language extensions via plugins

Can anyone please post a basic tutorial of how to use this thing ? this is very vague…

Yes, please.

The instructions are basically: “Copy the Lua source code into a folder (which I think I did right), and then this code goes at some place and does some stuff because some thing.”

Im sorry for the real newbie question… But how do you actually use the ScriptPLugin

I see all kinda post about how cool the script plugin is…

BUT… im so new … i dont see ANYWHERE that explains how to actually use the script plugin. Is it just me?

First off… Am i supposed to make a copy of the how scriptplugin and change it to be my own, kinda how blankplugin works…

or does it expose some kind of API that i code from or what?

I have made many mods to the CryMono for CryEngine3… We normally mod the engine code directly… Cool deal… there is a main
init function in the c++ engine that i mono_init up stuff… Then it basically mirrors all the “LUA” scriptcontext calls with monoscriptcontext
equivalent calls if this is a mono script and not lua script… Works great in CryEngine/CryMono.

After coming to Ue4… i did not want to go mod the engine directly (Like MonoUnrealEngine had to for its 4.4 preview).

I was hoping the ScriptPlugin provides some kind of API to expose all the blueprint stuff so i can then make mono_add_internal wrappers for.

I realize Others are try to do the same (mektek and muchdifferent)… BUT they are taking too long to get something out… anything… and
i need to be working on it now… cant wait any longer… i must attempt it myself… But cant find ANY docs on actually using the ScriptPlugin
to implement my own scripting language.

Please Help… Anyone… Any Explanations !!!

hello ,

I want to use lua for my project.
It’s didn’t have any step by step tutorial, so I try it in ue4.6 by myself

I trace the c++ code what happened ?
Then I found in your Class “ScriptFactory” & “ReimportScriptFactory” have problem
They didn’t have implement “virtual bool FactoryCanImport(const FString& Filename);”

So your factory will can’t import the file

I hope you fix it and write a tutorial in last version.

OK I just found the method to proof lua can run in ue4.6.

first go “ScriptFactory.h”
add


virtual bool FactoryCanImport(const FString& Filename);

and “ScriptFactory.cpp”
add


bool UScriptFactory::FactoryCanImport(const FString& Filename)
{
	if (FPaths::GetExtension(Filename) == TEXT("lua"))
	{
		return true;
	}
	return false;
}

then write “mytest.lua”


print("Lua in UE4!")
TickCounter = 0

function Tick1()
	TickCounter = TickCounter + 1
	return TickCounter
end


import like
2014-12-29 03 27 38.png
choose Script Component like
2014-12-29 03 30 10.png
and your Content Browser like
2014-12-29 03 31 06.png
Create a “Actor” Blueprint like
2014-12-29 03 32 19.png
in this blueprint add Component choose mytest like
2014-12-29 03 33 34.png
and the detail will have Mytest=>TickCounter like


go to graph make this blueprint
you must type function name
2014-12-29 03 32 19.png
add the blueprint into your scene like
2014-12-29 03 33 34.png

then play but sometime it will crash

final result like

Hi all.

Is there any way to use blueprints themselves as dynamic scripts? I mean, to be able to save blueprints as files and hot-reload them the same way as scripts while my game is running standalone (not in the editor)? This would make it unnecessary to use some 3rd party scripting languages, libraries and editors - just compile a single blueprint, replace the file in your game or even on the server and it gets picked up and reloaded. Is it possible, and if not, is it doable or maybe even planned for the future?

Hi ,

I watch the code.
I hope you can maintain this plugin, and give us some example with picture.

I know the “ScriptGeneratorPlugin” is very epic design.
It can auto generate function, porting from c++ to script(like lua).

but in html5 I have problem

first I use emscripten to build static library lua.bc for html5
then I modify ScriptPlugin.Build.cs to add rules for lua.bc like


else if (Target.Platform == UnrealTargetPlatform.HTML5)
                {
                    var LuaPath = Path.Combine("..", "Plugins", "ScriptPlugin", "Source", "Lua");
                    var LuaLibDirectory = Path.Combine(LuaPath, "Lib", "HTML5");
                    var LuaLibPath = Path.Combine(LuaLibDirectory, "lua.bc");
                    if (File.Exists(LuaLibPath))
                    {
                        Definitions.Add("WITH_LUA=1");
                        // Path to Lua include files
                        var IncludePath = Path.GetFullPath(Path.Combine(LuaPath, "Include"));
                        PrivateIncludePaths.Add(IncludePath);
                        // Lib file
                        PublicLibraryPaths.Add(LuaLibDirectory);
                        PublicAdditionalLibraries.Add(LuaLibPath);
                        Log.TraceVerbose("LUA Integration enabled: {0}", IncludePath);
                    }
                    else
                    {
                        Log.TraceVerbose("LUA Integration NOT enabled");
                    }
                }

then I compile ok. it gererate js and html file but get runtime error
ok I find the answer
I just forget compile some source file.

I upload lua.bc for anyone need html5 for lua use.
just rename lua.bc.txt to lua.bc.
I test in html5 it’s fine.

I found the problem of ScriptGeneratorPlugin
the cpp parser is not implement complete
so many function can’t call

I combined Zerobrane to debug lua
it’s fine, but many class lack most function

it’s big problem for ScriptGeneratorPlugin
it’s mean most function you can’t use in lua

it’s ignore function if not ufunction

Seeking Tutorial on how to use this feature from Blueprints (without using C++). Any direction will be greatly appreciated.

Hi damody,

Yes, there’s still work to be done regarding structs etc, so you are right that not all functions can be exported.

Do you mean it will ignore functions that are not UFUNCTIONS? If so, then yes and it will probably never change.

Hi TechLord,

Currently you will always need source for the engine as pre-built binaries are not integrated with Lua (you need Lua source code in the ScriptPlugin folder and then re-build everything to make it work). After that you can use it from blueprints as the way the plugin works is it creates blueprint classes from Lua scripts with the ability to execute Lua code instead of UE script (a.k.a. blueprints).

Hello , Thank you for taking time to clarify this feature.

Hi Robert,

Win64\UnrealHeaderTool-ScriptGeneratorPlugin.dll is the only plugin dll that gets included in the GitHub/Dependencies releases.

Is there a reason why this one dll always get’s in, and can it not? It we always have to delete it before dropping a new build into our P4 depot.

Thanks,

Kyle

Hi Robert,

I was wondering: would it would be possible to get the Lua code into the pre-built binaries? At the moment it’s a bit frustrating that there’s nothing between blueprints and C++. If I write in blueprints, it starts out very nice, but becomes difficult to maintain when it gets beyond a certain size. C++ is as good as it ever was, but it doesn’t offer the productivity of a scripting language. What I want is something in the middle and Lua would provide that.

Scriptplugin compile and work in 4.7 branch, but I always got this error when comping ScriptPlugin in 4.8 branch

It seems “GeneratedScriptLibraries.inl” never got generated by ScriptGeneratorPlugin. I noticed that now in 4.8, you have to enable ScriptPlugin first (FScriptGeneratorPlugin::SupportsTarget) to make ScriptGenerator happy, but even I do so, it still failed with same error.

Hi , in addition to enabling the plugin, you now also need to change this:



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

to this:



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

in ScriptPlugin.cpp. Sorry for the inconvenience, I’ll try to find some time to make it more automatic.

Thanks Robert! I do the modification and do a full rebuild, but still get the same error. How do you debug “ScriptGeneratorPlugin” when you develop it?

Build UnrealHeaderTool in debug configuration (it needs to be just ‘debug’, not ‘debug editor’ or anything else). You can just switch you active configuration to debug to do this and build UnrealHeaderTool. Do this after you build your target project and then go to Engine\Programs\UnrealHeaderTool\Saved\Logs\UnrealHeaderTool.log and copy the command line that’s in the log (note you only need the .uproject path and .manifest path) to UnrealHeaderTool’s command line in Visual Studio project properties (Configuration Properties -> Debugging -> Command Arguments). The set UnrealHeaderTool as your startup project and launch it in Visual Studio. You will now be able to debug UHT as well as the plugin (if it’s loaded).

Hi Robert, thanks for the debug tip! With the help of the good old debugger, it turns out there’s just one more change needed for a success ScriptPlugin 4.8 branch build:

In ScriptGeneratorPlugin.uplugin, change the “Category” from “Examples” to “UnrealHeaderTool.Code Generator.Generic”, otherwise the CodeGenerator from UHT wont be happy

Nice find! It’s a bug then! I’ll make sure it gets fixed for official