| 232 | } |
| 233 | |
| 234 | static 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 * |
no test coverage detected