19static nlua_env cond_env = LUA_NOREF;
26 if (cond_env != LUA_NOREF)
29 cond_env = nlua_newEnv();
31 WARN(_(
"Failed to load standard Lua libraries."));
43 nlua_freeEnv(cond_env);
58 if (strstr( cond,
"return" ) != NULL) {
59 lua_pushstring(naevL, cond);
63 lua_pushstring(naevL,
"return ");
64 lua_pushstring(naevL, cond);
67 ret = nlua_dobufenv(cond_env, lua_tostring(naevL,-1),
68 lua_strlen(naevL,-1),
"Lua Conditional");
71 WARN(_(
"Lua conditional syntax error: %s"), lua_tostring(naevL, -1));
74 WARN(_(
"Lua Conditional had a runtime error: %s"), lua_tostring(naevL, -1));
77 WARN(_(
"Lua Conditional ran out of memory: %s"), lua_tostring(naevL, -1));
80 WARN(_(
"Lua Conditional had an error while handling error function: %s"), lua_tostring(naevL, -1));
87 if (lua_isboolean(naevL, -1)) {
88 ret = !!lua_toboolean(naevL, -1);
96 WARN(_(
"Lua Conditional didn't return a boolean"));
100 lua_settop(naevL, 0);
int cond_check(const char *cond)
Checks to see if a condition is true.
void cond_exit(void)
Destroys the conditional subsystem.
int cond_init(void)
Initializes the conditional subsystem.
Header file with generic functions and naev-specifics.
int nlua_loadStandard(nlua_env env)
Loads the standard Naev Lua API.