summaryrefslogtreecommitdiff
path: root/library/LuaApi.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-08-20 23:04:01 +0400
committerAlexander Gavrilov2012-08-20 23:04:01 +0400
commit601a3a7927d50500b3dbdd2d20c5d7740a5484a1 (patch)
tree0acd09a61f5b5359d9a4197b8baef8043dda1f38 /library/LuaApi.cpp
parent38a07a4ca584e2cccc2c2814c35266ba33d692c8 (diff)
downloaddfhack-601a3a7927d50500b3dbdd2d20c5d7740a5484a1.tar.gz
dfhack-601a3a7927d50500b3dbdd2d20c5d7740a5484a1.tar.bz2
dfhack-601a3a7927d50500b3dbdd2d20c5d7740a5484a1.tar.xz
Add a script that implements a linked mechanism browser.
Diffstat (limited to 'library/LuaApi.cpp')
-rw-r--r--library/LuaApi.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp
index 112cc4fd..b8c1248b 100644
--- a/library/LuaApi.cpp
+++ b/library/LuaApi.cpp
@@ -1180,6 +1180,28 @@ static int screen_isDismissed(lua_State *L)
return 1;
}
+static int screen_doSimulateInput(lua_State *L)
+{
+ auto screen = Lua::CheckDFObject<df::viewscreen>(L, 1);
+ luaL_checktype(L, 2, LUA_TTABLE);
+
+ if (!screen)
+ luaL_argerror(L, 1, "NULL screen");
+
+ int sz = lua_rawlen(L, 2);
+ std::set<df::interface_key> keys;
+
+ for (int j = 1; j <= sz; j++)
+ {
+ lua_rawgeti(L, 2, j);
+ keys.insert((df::interface_key)lua_tointeger(L, -1));
+ lua_pop(L, 1);
+ }
+
+ screen->feed(&keys);
+ return 0;
+}
+
}
static const luaL_Reg dfhack_screen_funcs[] = {
@@ -1192,6 +1214,7 @@ static const luaL_Reg dfhack_screen_funcs[] = {
{ "show", &Lua::CallWithCatchWrapper<screen_show> },
{ "dismiss", screen_dismiss },
{ "isDismissed", screen_isDismissed },
+ { "_doSimulateInput", screen_doSimulateInput },
{ NULL, NULL }
};