MCPcopy Create free account
hub / github.com/DFHack/dfhack / CheckPen

Method CheckPen

library/LuaApi.cpp:655–681  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

653}
654
655void Lua::CheckPen(lua_State *L, Screen::Pen *pen, int index, bool allow_nil, bool allow_color)
656{
657 index = lua_absindex(L, index);
658
659 luaL_checkany(L, index);
660
661 if (lua_isnil(L, index))
662 {
663 if (!allow_nil)
664 luaL_argerror(L, index, "nil pen not allowed");
665
666 *pen = Pen(0,0,0,-1);
667 }
668 else if (lua_isuserdata(L, index))
669 {
670 *pen = *check_pen_native(L, index);
671 }
672 else if (allow_color && lua_isnumber(L, index))
673 {
674 *pen = Pen(0, lua_tointeger(L, index)&15, 0);
675 }
676 else
677 {
678 luaL_checktype(L, index, LUA_TTABLE);
679 decode_pen(L, *pen, index);
680 }
681}
682
683static int adjust_pen(lua_State *L, bool no_copy)
684{

Callers

nothing calls this directly

Calls 9

lua_absindexFunction · 0.85
luaL_checkanyFunction · 0.85
luaL_argerrorFunction · 0.85
lua_isuserdataFunction · 0.85
check_pen_nativeFunction · 0.85
lua_isnumberFunction · 0.85
luaL_checktypeFunction · 0.85
decode_penFunction · 0.85
PenClass · 0.50

Tested by

no test coverage detected