better handling of missing entry points

This commit is contained in:
Enno Rehling 2012-06-16 19:23:45 -07:00
parent 483615c458
commit 7618dc588d
1 changed files with 11 additions and 9 deletions

View File

@ -1286,7 +1286,7 @@ lua_State *lua_init(void) {
int eressea_run(lua_State *L, const char *luafile, const char *entry_point)
{
int err;
int err = 0;
global.vm_state = L;
/* run the main script */
@ -1303,14 +1303,16 @@ int eressea_run(lua_State *L, const char *luafile, const char *entry_point)
}
if (entry_point) {
lua_getglobal(L, entry_point);
err = lua_pcall(L, 0, 1, 0);
if (err != 0) {
log_lua_error(L);
abort();
if (lua_isfunction(L, -1)) {
log_debug("calling entry-point: %s\n", entry_point);
err = lua_pcall(L, 0, 1, 0);
if (err != 0) {
log_lua_error(L);
}
return err;
} else {
log_error("unknown entry-point: %s\n", entry_point);
}
} else {
err = lua_console(L);
}
return err;
}
return lua_console(L);
}