Original Post
I am attempting to call a function within a Lua script: cpp
if(luaL_loadfile(Lua_Handle, File) == 0) {
lua_getglobal(Lua_Handle, "OnLoop");
if(lua_pcall(Lua_Handle, 0, 1, 0) != 0) {
printf("Error running function `OnLoop': %s\n", lua_tostring(Lua_Handle, -1));
}
if(!lua_isnumber(Lua_Handle, -1)) {
printf("Returned parameter is invalid\n");
}
int Ret = lua_tonumber(Lua_Handle, -1);
lua_pop(Lua_Handle, 1);
}else{
printf("Unable to load Lua file\n");
}
script
function OnLoop()
io.write("I am looping!");
return 1;
end
When I try to call it, it returns: Error running function `OnLoop': attempt to call a nil value Returned parameter is invalid I appreciate any help offered, thanks. [Edited by - MetaCipher on October 15, 2007 12:48:49 PM]