I would like to know how to make a C-function and be able to tell Lua about it, then call it from Lua. I have all the Lua Libraries installed on my Mac OSX 10.4 computer.
There's an excellent example of Lua-C integration here and here.
If you just need to export a function into the global namespace, then:
f
) with signature lua_CFunction
.lua_register(L, "myfunc", f)
, with L being the Lua state, and function = f
.f
will be available in the global namespace as myfunc
.If you're going to use the stock interpreter then you might want to make a library. This guy wrote an article for Lua Programming Gems that explains how to do it. The sources are available online.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With