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

Function decode_pen

library/LuaApi.cpp:234–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234static void decode_pen(lua_State *L, Pen &pen, int idx)
235{
236 idx = lua_absindex(L, idx);
237
238 get_char_field(L, &pen.ch, idx, "ch", 0);
239
240 get_int_field(L, &pen.fg, idx, "fg", 7);
241 get_int_field(L, &pen.bg, idx, "bg", 0);
242
243 lua_getfield(L, idx, "bold");
244 if (lua_isnil(L, -1))
245 {
246 pen.bold = (pen.fg & 8) != 0;
247 pen.fg &= 7;
248 }
249 else pen.bold = lua_toboolean(L, -1);
250 lua_pop(L, 1);
251
252 get_int_or_closure_field(L, &pen.tile, idx, "tile", 0);
253
254 bool tcolor = get_int_field(L, &pen.tile_fg, idx, "tile_fg", 7);
255 tcolor = get_int_field(L, &pen.tile_bg, idx, "tile_bg", 0) || tcolor;
256
257 if (tcolor)
258 pen.tile_mode = Pen::TileColor;
259 else
260 {
261 lua_getfield(L, idx, "tile_color");
262 pen.tile_mode = (lua_toboolean(L, -1) ? Pen::CharColor : Pen::AsIs);
263 lua_pop(L, 1);
264 }
265
266 get_bool_field(L, &pen.keep_lower, idx, "keep_lower", false);
267 get_bool_field(L, &pen.write_to_lower, idx, "write_to_lower", false);
268 get_bool_field(L, &pen.top_of_text, idx, "top_of_text", false);
269 get_bool_field(L, &pen.bottom_of_text, idx, "bottom_of_text", false);
270}
271
272/**************************************************
273 * Per-world persistent configuration storage API *

Callers 1

CheckPenMethod · 0.85

Calls 7

lua_absindexFunction · 0.85
get_char_fieldFunction · 0.85
lua_getfieldFunction · 0.85
lua_tobooleanFunction · 0.85
get_int_or_closure_fieldFunction · 0.85
get_int_fieldFunction · 0.70
get_bool_fieldFunction · 0.70

Tested by

no test coverage detected