Giter Club home page Giter Club logo

luamachine's People

Contributors

brno32 avatar dgrouse96 avatar kartiku avatar knapsu avatar kristofmorva avatar niirozz avatar olathuss avatar parasetamon avatar pfoote avatar pomettini avatar rdeioris avatar schetle avatar smoozilla avatar unbit avatar yamaakir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

luamachine's Issues

Multiple states from different files?

Hi!

Thanks for the library!

In our use case we would need to be able to load multiple lua scripts which all use the same state class but not the same state. If I understood the code correctly, currently there is only one state per state class possible.

Is that correct or is there a way around it?

Make LUA value keeps losing the type

Make Lua value keeps losing the type, requiring a refresh of the node
Type recompile

After refreshing the node I lose the type enum
Refreshed

After a while I am able to refresh the node again and the enum type returns
Returned

Sometimes the warning returns and I lose the enum again

This happens every time I start the project, the issue is present in 4.26 (where the screenshots are from, no source modification) and 5.0

Access Error Outside of State File

Is there a way to return the error from a failed Run Code Asset node? Currently I can print the error out inside my LuaState subclass, but I'd like to be able to retrieve the error in the same place outside the state file where I'm instigating the execution of the code.

Issues with packaging

Hey! How's it going? Hope y'all are doing good.

First of all, as always, I want to thank you for the fantastic plugin! I work on a small indie game studio and we've bought it on the Marketplace a couple of years ago and have been using it extensively ever since.

We're currently having some issues with packaging the game with the Lua scripts. Our project structure looks something like this:"

├── Content
├── ├── Lua
├── ├── ├── Modules
├── ├── ├── ├── module1.lua
├── ├── ├── ├── module2.lua
├── ├── ├── ├── ...
├── ├── ├── Controllers
├── ├── ├── ├── controller1.lua
├── ├── ├── ├── controller2.lua
├── ├── ├── ├── ...
├── ├── ├── main.lua
├── ├── ...
├── ...
├── Project.uproject

The main.lua script requires and uses the modules and controllers exemplified (i.e module1.lua, controller1.lua, etc), and is directly called in the UE (Unreal Engine) project by using the Lua Run File blueprint node.

image

The main.lua file is not the only script directly called by UE, there are other calls like this one:

image

Everything works perfectly when running from within the engine, and it allows for easily editing the scripts without having to reimport them every time, which we strive as Lua users.

However, we can't seem to figure out how to make packaging work with this configuration. We've tried following the specifications on the Readme page by adding the Lua directory as a non-asset directory to be packaged:

image

Unfortunately, this doesn't work, as the packaged game is unable to find the Lua files, with all Lua Run File calls failing.

Manually copying our Lua folder and files to the newly packaged game Content folder does work, but this leaves our Lua files very much exposed, which would be less than ideal.

Could you guys help point us in the right direction?

Another thing, and I'm not sure if it's relevant or not, but in order for the Lua Run File calls to work, our Lua State blueprint has the following config:

image

If the Lua directory is removed from the config, the Lua Run File calls fail saying the file was not found.

Data Validation Error

Hello, my project has the Data Validation plugin enabled and it is throwing this error when compiling a widget that contains a Lua Code Box.

[AssetLog] C:\ConlangKit\Content\ConlangKit\UI\SoundChangeApplier\WBP_TemplateEditor.uasset: Leak Detected! LuaMultiLineEditableTextBox_0 (LuaMultiLineEditableTextBox) still has living Slate widgets, it or the parent HorizontalBox_1 (HorizontalBox) is keeping them in memory.  Make sure all Slate resources (TSharedPtr<SWidget>'s) are being released in the UWidget's ReleaseSlateResources().  Also check the USlot's ReleaseSlateResources().

It looks like it might be something to look into, so I though I'd let you know!

How calling functions in sequence with Delay.

Hi, this is how i run the lua code:
image
and this is my lua code:
image
and this is my open_dialog release:
image
image
How can I make sure there is a delay between "open_dialog"?
If i swap event to func, i cant enter delay.

How i can release this logic?

UE5: Couldn't build on linux as PlatformFilemanager.h was renamed

Hi

I've added the plugin into my project but it can't be compiled:

Plugins/LuaMachine/Source/LuaMachine/Private/LuaBlueprintFunctionLibrary.cpp:15:10: fatal error: 'HAL/PlatformFilemanager.h' file not found
#include "HAL/PlatformFilemanager.h"

I've found that the file has a new name in UE5: HAL/PlatformFileManager.h. I suppose building projects is not affected on Windows as its filesystem is case insensitive.

Here is a possible fix. I couldn't make a pull request myself.

#if !defined(ENGINE_MAJOR_VERSION) || ENGINE_MAJOR_VERSION < 5
#include "HAL/PlatformFilemanager.h"  // UE4
#else
#include "HAL/PlatformFileManager.h"  // UE5
#endif

It works with UE5 but I haven't tested with UE4 (maybe there is no need in !defined(ENGINE_MAJOR_VERSION) part).

Could someone add this? Thanks

Can Lua run only functions exposed to Blueprint?

I was wondering because the native python plugin for Unreal has a lot of shortcomings because only Blueprints are exposed, if this applies to LUA too? I might be misunderstanding the concept of this repository.

LuaTableKeyCall sends nil args

Messing around with this and I noticed that no matter how I set up LuaTableKeyCall it triggers the function correctly, but any args passed through it are nil

image

function Widget:Update(testString)
	print(testString)
end

I'm not entirely sure if I have just configured it wrong somewhere, but since the actual function is firing I really have no idea, ive tried it in different blueprints, global calls pass args correctly so I'm stumped.

fails to link on linux

apparently it tries to link the shared object for the plugin against a static lua library built without the PositionIndependentCode flag:

[6/8] Link (ld) libUE4Editor-LuaMachine.so
/home/kyra/src/UnrealEngine/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v15_clang-8.0.1-centos7/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-ld: /home/kyra/src/UnrealEngine/Engine/Plugins/LuaMachine/Source/ThirdParty/x64/liblua53_linux64.a(lstate.o): relocation R_X86_64_PC32 against symbol `lua_newstate' can not be used when making a shared object; recompile with -fPIC
/home/kyra/src/UnrealEngine/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v15_clang-8.0.1-centos7/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-ld: final link failed: bad value

see also https://stackoverflow.com/a/19768349/668125 for an explanation why this is happening, the binary static libs you provide were compiled without the -fPIC compiler flag, which would be required for the code to be relocatable in a shared lib.

a quick workaround was to just replace your Source/ThirdParty/x64/liblua53_linux64.a with the one from my distribution's lua (/usr/lib/liblua5.3.a), because that happened to be built with PIC, but i'd suggest you rebuild the one you're providing. or if you want i can send you my "known good" binary version?

Missing includes when packaging plugin but does not affect source build

Reproduction:

  • Create new empty C++ project (such as HostProject, just don't call it LuaMachine, cannot have a module with same name as project)
  • Clone LuaMachine into <Project>/Plugins/LuaMachine
  • Refresh VS Project files to include LuaMachine source
  • Open VS and Rebuild Solution, everything builds correctly (usually, sometimes had heap allocation failures with 64GB of ram)
  • Open plugin browser, press Package on the plugin
  • Fails due to 2 files missing ENGINE_MAJOR_VERSION macros

Solution:

  • Add #include "Runtime/Launch/Resources/Version.h" to LuaCommandExecutor.h and LuaMultiLineEditableTextBox.h immediately before any generated headers (LuaMultiLineEditableTextBox has a generated header, put this include before it)

Git Diff (didn't feel like forking for a 2 line PR):

diff --git a/Source/LuaMachine/Public/LuaCommandExecutor.h b/Source/LuaMachine/Public/LuaCommandExecutor.h
index 6956cb5..8864a5c 100644
--- a/Source/LuaMachine/Public/LuaCommandExecutor.h
+++ b/Source/LuaMachine/Public/LuaCommandExecutor.h
@@ -5,6 +5,7 @@
 #include "CoreMinimal.h"
 #include "HAL/IConsoleManager.h"
 #include "Framework/Commands/InputChord.h"
+#include "Runtime/Launch/Resources/Version.h"

 class ULuaState;

diff --git a/Source/LuaMachine/Public/LuaMultiLineEditableTextBox.h b/Source/LuaMachine/Public/LuaMultiLineEditableTextBox.h
index 6661fcd..96a9ad2 100644
--- a/Source/LuaMachine/Public/LuaMultiLineEditableTextBox.h
+++ b/Source/LuaMachine/Public/LuaMultiLineEditableTextBox.h
@@ -5,6 +5,7 @@
 #include "CoreMinimal.h"
 #include "Components/TextWidgetTypes.h"
 #include "Components/MultiLineEditableTextBox.h"
+#include "Runtime/Launch/Resources/Version.h"
 #include "LuaMultiLineEditableTextBox.generated.h"

 USTRUCT(BlueprintType)

Server and Client sharing LuaState in single process PIE

Hey there!

I've recently played around with LuaMachine and replication and noticed some weirdness going on: When launching 2 instances in PIE using "run in one process" and executing an IsServer() call would report FALSE on the server when executed through an RPC which calls a lua function calling the IsServer() function. The issue (naturally) does not happen when running with multiple processes, so it appears like the two instances somehow share the same luastate.
I've first experienced it in 4.26, but also reproduced it in 4.27 and 5.0, each with latest plugin version available. Also attaching two test projects demonstrating it both in 4.27 and 5.0. Just run them with 2 players and press space on the client, this will execute the chain of functions and print each step on screen and in the log.
LuaTest.zip
LuaTest_UE5.zip

As its a bit complicated to understand perhaps, lets go through the setup step by step! :D

  1. the LuaState defines a function IsServer() which just returns the result of the engines IsServer() to check the state:
    image

  2. A simple Lua script making a table with a single function that just executes the IsServer() function above and compares it with the expected result (which is coming from a native call of the engines IsServer() function):

TestActor = {}

function TestActor:TestFunction(msg, should_be_server)
    mytype = IsServer() and "SERVER" or "CLIENT"
    wrongType = IsServer() ~= should_be_server

    if wrongType then msg = msg .." ---- wrong type reported!" end

    Print("Lua: "..mytype..": "..msg, wrongType)
end
  1. then, in a test actor, making a copy of the table above and keeping it as a reference for later calls:
    image

  2. in the test actor, a call into the lua function, providing the native result of IsServer():
    image

  3. and finally the chain of RPCs executed in the test actor calling the lua function in each step to report the results of the IsServer() function:
    image

when executing this, this is the print out:

[BP_TestPawn_C_1] Server: BP_TestPawn_C_1: BeginPlay SERVER
[BP_LuaState_Test_C_0] Server: BP_LuaState_Test_C_0: Lua: SERVER: BeginPlay
[BP_TestPawn_C_0] Client 1: BP_TestPawn_C_0: BeginPlay CLIENT
[BP_LuaState_Test_C_0] Client 1: BP_LuaState_Test_C_0: Lua: CLIENT: BeginPlay
[BP_TestPawn_C_1] Client 1: BP_TestPawn_C_1: BeginPlay CLIENT
[BP_LuaState_Test_C_0] Client 1: BP_LuaState_Test_C_0: Lua: CLIENT: BeginPlay
[BP_TestPawn_C_0] Client 1: BP_TestPawn_C_0: Input CLIENT
[BP_LuaState_Test_C_0] Client 1: BP_LuaState_Test_C_0: Lua: CLIENT: input
[BP_TestPawn_C_1] Server: BP_TestPawn_C_1: received ServerRPC SERVER
[BP_LuaState_Test_C_0] Client 0: BP_LuaState_Test_C_0: Lua: CLIENT: on server ---- wrong type reported!
[BP_TestPawn_C_1] Server: BP_TestPawn_C_1: received MulticastRPC SERVER
[BP_LuaState_Test_C_0] Client 0: BP_LuaState_Test_C_0: Lua: CLIENT: multicast ---- wrong type reported!
[BP_TestPawn_C_0] Client 1: BP_TestPawn_C_0: received MulticastRPC CLIENT
[BP_LuaState_Test_C_0] Client 1: BP_LuaState_Test_C_0: Lua: CLIENT: multicast

As you can see, both client and server execute within the same lua state, and despite the native call reports to be the server properly, the call from the lua function (executed from the RPC) is reporting on the server to be "Client 0".

I'm quite sure this has to do with the lua state being a singleton, but for some reason client and server share the same singleton instead of creating its own. Not sure if that is easily fixable or at all. Workaround for now is to always run in multiple processes, but this makes testing and debugging really slow and cumbersome...

Maybe I'm also doing something stupid though :D

Thx for your support and that awesome plugin!

UE 5.3 support not on the marketplace

I have bought the plugin from the UE marketplace because I wanted to use it with an existing project, but the marketplace version does not have support for 5.3. When will it be available?

Assigning a metatable to _G

It would be awesome to have a similar logic as ULuaUserDataObject::ReceiveLuaMetaIndex(Key) and ULuaUserDataObject::ReceiveLuaMetaNewIndex(Key, Value), but for ULuaState so you would be able to intercept whenever the global table tries to access a field that does not exist etc.

The goal for me is to intercept simple code lite this:
ULuaBlueprintFunctionLibrary::LuaRunString(GetWorld(), URCLuaReflectionState::StaticClass(),"Foo");
and be able to return a dynamic FLuaValue based on the Key:"Foo" from a C++ callback.

Projects using LuaMachine

It would be great to add a section in the README where people can list UE projects that use LuaMachine. It would really boost the confidence for potential users as well as provide some pointers for researching how LuaMachine is implemented in different projects.

Cast to la

I need cast from lua boolean to unreal boolean, can you implement it?
Thaks.

Replacement print function causes issues when called from coroutine

Lua coroutine thread -> C TableFunction_print -> Lua tostring call causes issues as crosses the Lua/C/Lua barrier during coroutine, using lua_tostring instead of global "tostring" fixes the issue (and is a bit less complex)

https://github.com/rdeioris/LuaMachine/blob/master/Source/LuaMachine/Private/LuaState.cpp#L792

int ULuaState::TableFunction_print(lua_State *L)
{
	ULuaState* LuaState = ULuaState::GetFromExtraSpace(L);
	TArray<FString> Messages;

	int n = lua_gettop(L);
	for (int i = 1; i <= n; i++)
	{		
		Messages.Add(UTF8_TO_TCHAR(lua_tostring(L, i)));
	}
	LuaState->Log(FString::Join(Messages, TEXT("\t")));
	return 0;
}

Character's functions from state

Hi, I am trying to call functions of a Character from a Widget run, I'm getting my Character from my Lua State but when I try to call Characters function, nothing happens, and nothing in my console..

In game:
image

Commands + when pressing run:
image

GetPlayer()
image

Player's Lua Component's Content
image

Able to have latent calls?

Hey, I want to use this to implement robots in my puzzle game.

An example Lua code would look like this:

robot.walkForward()
robot.turnLeft()
robot.walkForward()

As you can see, I'd need the calls to be "blocking", or non-returning until the robot fully finished moving. Is that possible? Thanks!

Is there a way to get the actual table reference string?

Hi! First of all, amazing plugin!

When casting a table to string and printing I get something like table: 5, which appears to be the registry entry id of the table, which is changeable, if I understand this correctly.

Is there a way to get the table: 00AFA376 string? I have a table indexed table that I'm trying to reflect as a String to Blueprint map.

Thanks again!

[UE4.26] Compilation Issues

In file LuaBlueprintFunctionalLibrary.cpp on line 570 and 635, there are issues with

TSharedRef<IHttpRequest> HttpRequest = FHttpModule::Get().CreateRequest();
...
HttpRequest->SetURL(URL);

Compilation Error: LuaBlueprintFunctionLibrary.cpp(570): [C2440] 'initializing': cannot convert from 'TSharedRef<IHttpRequest,ESPMode::ThreadSafe>' to 'TSharedRef<IHttpRequest,ESPMode::NotThreadSafe>'

Return with "Lua Create Object" returns received parameter instead

If a Blueprint Function tries to return a LuaObject, it instead returns the received parameter.

I created a Blueprint function like this:

image
It receives a LuaValue as parameter (does nothing with it), then creates an object (Lua Create Object) from an asset and returns it.

Then I added that function to the global Lua table:
image

And called it from Lua, passing "banana" as the parameter:
image

And this was printed:
image

As you can see, instead of print something like userdata: 000002CD078BF7C8, it printed the received parameter "banana".

ADDITIONAL INFO: I managed to work around this bug by creating a table in the blueprint, putting the object inside the table, and then returning that table. That way, I am able to access the correct userdata by doing TestObjectReturn("banana")[1].

Supporting different platforms

Hello, how's it going?

First things first, I wanted to use this as a way to thank you for the insanely good job on this Plugin, it is currently being used to power our MVC architecture with a LUA core in my game studio's main project, Primateria. We're using the marketplace plugin in production and it's saved us a ton of development time.

Recently we've received a lot of requests to release the game on Android and other platforms, so I wanted to ask if it would be possible to package Lua Machine for the many different platforms supported by Unreal Engine, such as consoles and Linux. Our main concern is Android, but the more, the merrier!

Thanks once again for the incredible work! :)

4.26 support?

Will you be adding support for 4.26 for the Marketplace version? Right now it can't be installed on 4.26.

How to package with `LuaCode`?

All my lua code is in LuaCode assets, but after packaging when I try to retrieve the code, I just get a blank string. I'm not using any non-asset content, but is there something to configure during packaging?

The instructions say

Transform your scripts (just drag them in the content browser) to LuaCode assets and eventually fix the RequireTable.

I'm not doing any imports in my lua code.

Support UTF-8 files with BOM encoding attached.

As discussed in Discord:

I created a Lua file in Jetbrains Rider, and had the setting to include the BOM turned on. This resulted in Unreal importing the file with some garbage characters at the front, rather than handling those characters properly. This was only fixed by creating a new file after I'd turned the setting off.

The plugin should import files while excluding these characters.

image
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.