diff options
| author | Alexander Gavrilov | 2012-08-19 17:53:25 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-08-19 17:53:25 +0400 |
| commit | cacb082416667ec4309d85e934068ded041d21b8 (patch) | |
| tree | f34c045461dfea3c4a5054d90b4042050bf9857f /library/LuaApi.cpp | |
| parent | 30f71ff5106d271d04bfa26b976441cfa9b2abf6 (diff) | |
| download | dfhack-cacb082416667ec4309d85e934068ded041d21b8.tar.gz dfhack-cacb082416667ec4309d85e934068ded041d21b8.tar.bz2 dfhack-cacb082416667ec4309d85e934068ded041d21b8.tar.xz | |
Add a stupid example of a lua-controlled viewscreen.
Diffstat (limited to 'library/LuaApi.cpp')
| -rw-r--r-- | library/LuaApi.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index d296a2e5..0f3ed935 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -196,7 +196,15 @@ static bool get_int_field(lua_State *L, T *pf, int idx, const char *name, int de static void decode_pen(lua_State *L, Pen &pen, int idx) { - get_int_field(L, &pen.ch, idx, "ch", 0); + idx = lua_absindex(L, idx); + + lua_getfield(L, idx, "ch"); + if (lua_isstring(L, -1)) + pen.ch = lua_tostring(L, -1)[0]; + else + get_int_field(L, &pen.ch, idx, "ch", 0); + lua_pop(L, 1); + get_int_field(L, &pen.fg, idx, "fg", 7); get_int_field(L, &pen.bg, idx, "bg", 0); |
