cocos2d-x + Lua C++调用Lua函数

本人按照网上的例子写了一个C++调用lua函数的例子 最后输出的结果iResult = 0 请各位大神们给看看为什么 谢谢!!
int ret = 0 ;
lua_State* pL = lua_open();
luaopen_base(pL);
ret = luaL_loadfile(pL, “src/controller.lua”);
if ( ret != 0 )
{
int a= 1;
int v = 2;
a = v+3;
//err_return(-1,“luaL_loadfile failed”) ;
}
lua_getglobal(pL, “helloAdd”);
/* 把函数所需要的参数入栈 /
lua_pushnumber(pL, 10);
lua_pushnumber(pL, 5);
/

这里用lua_call程序会直接宕掉 用lua_pcall不会
*/
lua_pcall(pL, 2, 1,0);
int iResult = lua_tonumber(pL, -1);
CCLOG(“iResult = %d”, iResult);

controller.lua 内容

myName = “beauty girl”
helloTable = {name = “mutou”, IQ = 125}
function helloAdd(num1, num2)
print("Number of touches: ")
return (num1 + num2)

end

luaL_loadfile -> luaL_dofile

我把luaL_loadfile换成了luaL_dofile还是一样结果等于0呀。。。我是在cocos2d-x3.2版本的实例里加的 求帮忙谢谢!!!

cocos2d-x KO榜交流群
技术交流群,欢迎大家加入,共同探讨进步,群号361211771,也可以点击链接加入群【cocos2d-x KO榜】:http://jq.qq.com/?_wv=1027&k=JPz0JS