LuaMachine icon indicating copy to clipboard operation
LuaMachine copied to clipboard

Assigning a metatable to _G

Open LarsIngo opened this issue 2 years ago • 2 comments

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.

LarsIngo avatar May 10 '23 16:05 LarsIngo

Issue opened after discussion on discord: Screenshot 2023-05-10 181553

LarsIngo avatar May 10 '23 16:05 LarsIngo

Adding the metatable as you described workes for "Foo.Bar", "Bar = Foo". However, it does not trigger for only "Foo" (expected behaviour?) image

LarsIngo avatar May 11 '23 09:05 LarsIngo