lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

If I define a "local" function, as such:

local function Dispatch(archive)

...and I want to call this function from C++, I do not think I can use the
lua_getglobal() call:

    m_pThreadState = lua_newthread(m_MasterLuaState);
    //Load/define the above "Dispatch" routine local to this thread.
    luaL_loadbuffer(m_pThreadState, m_ScriptBody, strlen(m_ScriptBody),
    lua_getglobal(m_pThreadState, "Dispatch"); //UH-OH!! PROBLEM HERE!!
    lua_pcall(m_pThreadState, 1, 0, 0);

So how do I specify/push the local function "Dispatch" in preperation for
the call?  Again, I assume I cannot use the lua_getglobal() call, because
the "Dispatch" function is defined as "local" to the m_pThreadState.  What
do I do?