From 1f15e4d47ec593cc5bc803d6e5bdec720c48b07b Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 18 Sep 2022 08:19:56 -0700 Subject: [PATCH] expose Gui::getMousePos() to Lua --- library/LuaApi.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 70cb01dfc..b556e5737 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1523,6 +1523,12 @@ static int gui_getDwarfmodeViewDims(lua_State *state) return 1; } +static int gui_getMousePos(lua_State *L) +{ + Lua::PushPosXYZ(L, Gui::getMousePos()); + return 3; +} + static const LuaWrapper::FunctionReg dfhack_gui_module[] = { WRAPM(Gui, getCurViewscreen), WRAPM(Gui, getFocusString), @@ -1555,6 +1561,7 @@ static const LuaWrapper::FunctionReg dfhack_gui_module[] = { static const luaL_Reg dfhack_gui_funcs[] = { { "getDwarfmodeViewDims", gui_getDwarfmodeViewDims }, + { "getMousePos", gui_getMousePos }, { NULL, NULL } }; @@ -2282,9 +2289,7 @@ static const LuaWrapper::FunctionReg dfhack_screen_module[] = { static int screen_getMousePos(lua_State *L) { - auto pos = Screen::getMousePos(); - lua_pushinteger(L, pos.x); - lua_pushinteger(L, pos.y); + Lua::PushPosXY(L, Screen::getMousePos()); return 2; }