Relative Content

Tag Archive for lualuaclua-c++-connection

How to call lua functions from another language

Trying to make an engine that calls other language from lua code. And the problem that I stuck into is callbacks.
Converting strings, ints and so on is easy, but what to do with functions?
Lua API has lua_isfunction to check that function argument is function, but how do I store it to call it later when called script needs it? There is lua_topointer, that can store function, but I don’t see how to call that stored pointer.

Lua C – Is there a way to keep a value in C, but still have it not garbage collected?

I am creating a thread in lua c, but i want to keep it just in C, without making it a variable in the environment/etc. But when i throw away the thread value that gets pushed by lua_newthread, it gets garbace collected shortly after, and so becomes useless.
In this thread i want to run arbitrary lua code passed by the user, allowing them to use the exclusive functions/variables that are isolated from other threads.