Lua: allow calling impossible

This commit is contained in:
Pasi Kallinen
2022-03-16 16:58:42 +02:00
parent d1ca594d1c
commit 811299edaf
2 changed files with 24 additions and 0 deletions

View File

@@ -187,6 +187,15 @@ Example:
nh.deltrap(x, y);
=== impossible
Issue an impossible, signaling a possible error in the code.
Example:
nh.impossible("Something errory happened!");
=== ing_suffix
Construct a gerund (a verb formed by appending "ing" to a noun).

View File

@@ -34,6 +34,7 @@ static int nhl_deltrap(lua_State *);
#if 0
static int nhl_setmap(lua_State *);
#endif
static int nhl_impossible(lua_State *);
static int nhl_pline(lua_State *);
static int nhl_verbalize(lua_State *);
static int nhl_parse_config(lua_State *);
@@ -491,6 +492,19 @@ nhl_getmap(lua_State *L)
RESTORE_WARNING_CONDEXPR_IS_CONSTANT
/* impossible("Error!") */
static int
nhl_impossible(lua_State *L)
{
int argc = lua_gettop(L);
if (argc == 1)
impossible("%s", luaL_checkstring(L, 1));
else
nhl_error(L, "Wrong args");
return 0;
}
/* pline("It hits!") */
static int
nhl_pline(lua_State *L)
@@ -1154,6 +1168,7 @@ static const struct luaL_Reg nhl_functions[] = {
{"abscoord", nhl_abs_coord},
{"impossible", nhl_impossible},
{"pline", nhl_pline},
{"verbalize", nhl_verbalize},
{"menu", nhl_menu},