Download

how to find a native function by name and call it with marshalled params?

hi,all~
i want to write a lua plugin,
the principle is simple:
register everything(class and function) to script,
make call between c++ and lua.
that has been done many times in past projects.

the key problem is how to produce the big amount of glue code.
maybe i can custom the unrealheadertool, let it produce wraper function for everyone
but instead of that, i’d like to reuse the “Inspect system” made by UE:
every UObject-based class has a UClass instance in runtime,
through it we can enum all properties and member functions?
and then, we can call these functions with a universal mode as:“func->call(param_stack)”
with this , we may even get a thin script layer which only make dynamic forward of call:)

so, could we? how to do that: find function and call it?

Check out this thread: https://forums.unrealengine.com/showthread.php?351-UFUNCTION()-UPROPERTY()-USTRUCT()-etc-macros-where-is-the-documentation

Also, the documentation: https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Functions/index.html

Finally, if you look for how the UFUNCTION() and similar macros are implemented, and the code they generate, and then follow that rabbit hole using “go to definition” and recursive find in the C++ code base, you will find what you’re looking for.

The short answer is: Yes, it is possible to tie the UFUNCTIONS and UCLASSES of Unreal C++ to Lua.

There used to be an official lua plugin, but it was abandoned a while ago.
Maybe it still works and you can see how it’s done?