#if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_TARGET)
extern lua_State * nhl_init(void);
+extern void nhl_done(lua_State *);
extern boolean nhl_loadlua(lua_State *, const char *);
extern boolean load_lua(const char *);
extern void nhl_error(lua_State *, const char *) NORETURN;
* a structure of their own elsewhere some day.
*/
boolean debug_fuzzer; /* fuzz testing */
+ boolean in_lua; /* executing a lua script */
boolean defer_plname; /* X11 hack: askname() might not set g.plname */
boolean herecmd_menu; /* use menu when mouseclick on yourself */
boolean invis_goldsym; /* gold symbol is ' '? */
so that it's hidden from '#wizwhere' feedback. */
}
- lua_close(L);
+ nhl_done(L);
for (i = 0; i < pd.n_brs; i++) {
free((genericptr_t) pd.tmpbranch[i].name);
if (keependgame && i == astral_level.dnum)
continue;
if (g.luathemes[i]) {
- lua_close((lua_State *) g.luathemes[i]);
+ nhl_done((lua_State *) g.luathemes[i]);
g.luathemes[i] = (lua_State *) 0;
}
}
if ((themes = nhl_init()) != 0) {
if (!nhl_loadlua(themes, fname)) {
/* loading lua failed, don't use themed rooms */
- lua_close(themes);
+ nhl_done(themes);
themes = (lua_State *) 0;
} else {
/* success; save state for this dungeon branch */
{
lua_State *L = luaL_newstate();
+ iflags.in_lua = TRUE;
luaL_openlibs(L);
nhl_set_package_path(L, "./?.lua");
l_obj_register(L);
if (!nhl_loadlua(L, "nhlib.lua")) {
- lua_close(L);
+ nhl_done(L);
return (lua_State *) 0;
}
return L;
}
+void
+nhl_done(lua_State *L)
+{
+ lua_close(L);
+ iflags.in_lua = FALSE;
+}
+
boolean
load_lua(const char *name)
{
}
give_up:
- lua_close(L);
+ nhl_done(L);
return ret;
}
free((genericptr_t) synopsis);
if (fallback_msgid)
free((genericptr_t) fallback_msgid);
- lua_close(L);
+ nhl_done(L);
return res;
}