LUAL_CHECKOPTION(3) | Library Functions Manual | LUAL_CHECKOPTION(3) |
luaL_checkoption
—
checks whether the function argument is a string, function
indicator [-0, +0, v]
#include
<lauxlib.h>
int
luaL_checkoption
(lua_State
*L, int narg,
const char *def,
const char *const
lst[]);
luaL_checkoption
()
checks whether the function argument narg is a string
and searches for this string in the array lst (which
must be NULL
-terminated). Returns the index in the
array where the string was found. Raises an error if the argument is not a
string or if the string cannot be found.
If def is not NULL
,
the function uses def as a default value when there is no argument
narg or if this argument is
nil
.
This is a useful function for mapping strings to C enums. (The usual convention in Lua libraries is to use strings instead of numbers to select options.)
Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes, Lua 5.1 Reference Manual.
The luaL_checkoption
() manual page is
based on Lua Reference Manual 5.1 and was created by Sergey Bronnikov.
July 24, 2022 | Debian |