在Android中运行时不会调用Lua C函数

时间:2012-12-05 10:06:23

标签: android c++ lua

我有这种情况。在我继续讨论我的问题之前,请查看下面的代码(我无法在标题中正确描述)

我的lua初始化代码:

luaState = luaL_newstate();
luaL_openlibs(luaState);
RegisterFunctions(luaState);

我的lua加载代码:

try {
        luaL_dofile(luaState, scriptPath.c_str());
    }
    catch (...) {
        std::cout << "LUA ERROR: Could not load file " << std::endl;

    }
    loaded_.push_back(filename);

我定义C函数的部分:

int testFunction(lua_State* L)
{
    std::cout << "Test" << std::endl;
    return 0;
}
void RegisterFunctions(lua_State* L)
{
    lua_register(L, "testFunction", testFunction);

}

我的Lua脚本:

test = {};

function test:testCallback(me)
    testFunction();
end

这些代码能够在Android中正确构建和运行。但是,当调用testFunction()时,它没有进入我定义的C函数。除此之外一切都有效。我也在IOS和IOS上测试了它,它也进入了testFunction。问题只发生在Android上,我不知所措。如果有人有任何建议,我将不胜感激。

0 个答案:

没有答案