现在的位置: 首页 > 综合 > 正文

lua错误信息

2013年11月07日 ⁄ 综合 ⁄ 共 547字 ⁄ 字号 评论关闭
int _tmain(int argc, _TCHAR* argv[])
{
    Test::Tst_B* b = new Test::Tst_B;         // instance used in Lua code

    lua_State* L = lua_open();
    luaL_openlibs(L);
    tolua_tclass_open(L);

    int top = lua_gettop(L);

    int loaderr = luaL_loadfile(L,"tclass.lua");
    if (loaderr)
    {
        const char* errMsg = lua_tostring(L,-1);
        lua_settop(L,top);
#ifdef _DEBUG
        ::printf_s("[LuaScriptModule]: %s\n", errMsg);
#endif
    }

    // call it
    if (lua_pcall(L,0,0,0))
    {
        const char* errMsg = lua_tostring(L,-1);
        lua_settop(L,top);
#ifdef _DEBUG
        ::printf_s("[LuaScriptModule]: %s\n", errMsg);
#endif
    }

    lua_settop(L,top); // just in case :P 

    lua_close(L);

    delete b;
    return 0;
}

抱歉!评论已关闭.