Registering Static Functions
It is also possible to register static functions with the LuaAPI which allows you to call a function within a script that affects your program without needing to pass objects to and from Lua.
Using Static Functions
extern int Outputi(const int& i, const float& f) {
std::cout << "Success: " << i << " + " <<
f << "!" << std::endl;
return 0;
}
luaApi.RegisterStaticFunction<int, const int&,
const float&>("uair.tmpStcFncif", &Outputi);
try {
std::string scr = R"(
uair.tmpStcFncif(1, 2.4)
)";
luaApi.CallString(scr);
} catch (std::exception& e) {
std::cout << e.what() << std::endl;
}