Hello :
I'm a new user of lua,I'm tring to call a simple function in file.
in my application:
lua_State* luaVM = lua_open();
if (NULL == luaVM)
{
MyEngineERR("luaL_error Initializing lua\n");
return -1;
}
if (luaL_loadfile(luaVM,filename)!=0)
{
MyEngineERR((LPSTR)lua_tostring(luaVM, -1));
lua_pop(luaVM, 1);
lua_close(luaVM);
return -1;
}
// loading is succesful
const char name[]="add";
lua_getglobal(luaVM,name);
//when I remove this line pcall succesful,or I will get a "attempt to call a nil value"
if(lua_pcall(luaVM,0,0,NULL)!=0)
{
MyEngineERR((LPSTR)lua_tostring(luaVM, -1));//
lua_pop(luaVM, 1);
lua_close(luaVM);
}
in the scripts file:
Am I do somethin wrong?and I'm using lua 5.1.Thanks for any suggestions.