rdeioris / LuaMachine

Unreal Engine Plugin for Lua APIs implementation
MIT License
581 stars 120 forks source link

Return with "Lua Create Object" returns received parameter instead #22

Closed purei-shatsu closed 3 years ago

purei-shatsu commented 3 years ago

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].

rdeioris commented 3 years ago

@lp-pinheiro hello, thanks for reporting, i am achecking it, is this on latest master or on an official release ?

rdeioris commented 3 years ago

@lp-pinheiro i did various tests, and i was not able to reproduce it. Is it possible you are calling TestObjectReturn from a coroutine ? in the current master there is a fix for object creation in coroutine: https://github.com/rdeioris/LuaMachine/commit/c1978cbd422fe19474aa4dde23f77489ab2b6df9

purei-shatsu commented 3 years ago

I tested on the release Marketplace 20201211. And indeed, I was calling from a coroutine.

rdeioris commented 3 years ago

@lp-pinheiro great, just use latest master and it should be fixed