LUA_TOBOOLEAN(3) Library Functions Manual LUA_TOBOOLEAN(3)

lua_tobooleanconverts the Lua value to a C boolean value

#include <lua.h>

int
lua_toboolean(lua_State *L, int index);, function indicator [-0, +0, -]

() converts the Lua value at the given acceptable index to a C boolean value (0 or 1).

Like all tests in Lua, lua_toboolean() returns 1 for any Lua value different from and ; otherwise it returns 0. It also returns 0 when called with a non-valid index. (If you want to accept only actual boolean values, use lua_isboolean(3) to test the value's type.)

lua_isboolean(3)

Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes, Lua 5.1 Reference Manual.

The lua_toboolean() manual page is based on Lua Reference Manual 5.1 and was created by Sergey Bronnikov.

July 14, 2022 Debian