Closed sizeoftrickster closed 2 years ago
I think that writing an actual C-style function that did the job would require you to have the Lua state available as a global variable:
void GameloopHook() {
sol::function(lua["Handler"])();
}
That's not nice. But you can make a function wrapper that takes care of it by just saying
sol::function gameloopHook{lua["Handler"]};
which only requires the Lua state to be available at the point of definition. The sol::function
isn't a function pointer, but can be passed in anywhere a std::function<void()>
is expected.
Alternatively, you can wrap the call in a lambda that captures the Lua state.
Hi all. Please help to implement such a thing. I need the content of one function to be passed to a hook.