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

Function adjust_pen

library/LuaApi.cpp:683–724  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

681}
682
683static int adjust_pen(lua_State *L, bool no_copy)
684{
685 lua_settop(L, 4);
686
687 Pen pen;
688 int iidx = 1;
689 Lua::CheckPen(L, &pen, 1, true, true);
690
691 if (!lua_isnil(L, 2) || !lua_isnil(L, 3) || !lua_isnil(L, 4))
692 {
693 if (lua_isnumber(L, 2) || lua_isnil(L, 2))
694 {
695 if (!pen.valid())
696 pen = Pen();
697
698 iidx = -1;
699
700 pen.fg = luaL_optint(L, 2, pen.fg) & 15;
701 pen.bg = luaL_optint(L, 3, pen.bg);
702
703 if (!lua_isnil(L, 4))
704 pen.bold = lua_toboolean(L, 4);
705 else if (!lua_isnil(L, 2))
706 {
707 pen.bold = !!(pen.fg & 8);
708 pen.fg &= 7;
709 }
710 }
711 else
712 {
713 iidx = 2;
714 Lua::CheckPen(L, &pen, 2, false, false);
715 }
716 }
717
718 if (no_copy && iidx > 0 && lua_isuserdata(L, iidx))
719 lua_pushvalue(L, iidx);
720 else
721 Lua::Push(L, pen);
722
723 return 1;
724}
725
726static int dfhack_pen_parse(lua_State *L)
727{

Callers 2

dfhack_pen_parseFunction · 0.85
dfhack_pen_makeFunction · 0.85

Calls 8

lua_settopFunction · 0.85
lua_isnumberFunction · 0.85
lua_tobooleanFunction · 0.85
lua_isuserdataFunction · 0.85
lua_pushvalueFunction · 0.85
PushFunction · 0.85
validMethod · 0.80
PenClass · 0.50

Tested by

no test coverage detected