<something used to be here... its gone now>
<something used to be here... its gone now>
Last edited by Master674; 10-15-2012 at 12:54 PM.
If I understand you correctly you want something like this
Code:lua_Debug d = {0}; int call_depth = 1; // adjust as needed, or loop while incrementing it until lua_getstack returns 0 for a full stack trace lua_getstack(l, call_depth, &d); lua_getinfo(l, "Sln", &d); if(d.short_src[0] == '[') // lazy hack. C callbacks also start with '[' but since we aren't checking call depth 0 it's okey. callbacks normally don't call other callbacks directly. std::wcout << "callback called from dostring(\"" << d.source << "\")" << std::endl; else std::wcout << "callback called from file: '" << d.source << "' function: '" << (d.name ? d.name : "(none)") << "' line: " << d.currentline << std::endl;
Last edited by _Mike; 05-11-2012 at 10:43 PM.
Your question is fairly nebulous but I think I see what you want to do.
First "SetTimedEvent()" is not a known/standard API function.
Are you talking about this?: Simple C++ Timer Wrapper - CodeProject
At any rate one can with a degree of certainty assume that your SetTimedEvent() calls some kind of callback function after a given time or even periodically.
You can run any number of Lua instances at any given time only limited by how many threads and memory you have on your platform.
What you'll have to do from your callback is create a Lua state for each instance using the C API like this
Then load the Lua libs if need, load the text file in then pcall it.Code:lua_State *L = luaL_newstate()
Look at the Lua console source ("Lua.c" I think) to see how it is done there for a more detailed example.Code:luaL_openlibs(L); luaL_loadfile(L, szFile); lua_pcall(L, 0, LUA_MULTRET, 0); lua_close(L);
Note each Lua state will be in it's own context. If you need to share context between them then you will need to make a custom setup for it.
There are some existing setups including a muti-threaded Lua version, etc., on LuaForge and some other sights; just Google for it.
If you need additional functionality (what you mean by Lua callbacks?) it's pretty easy to add with a DLL, or using LuaJIT you might be able to use it's FFI library to directly interface with API calls, etc.
Looks to me you need to research the Lua API in detail plus look around some (again Google for it).