expose Gui::getMousePos() to Lua

develop
Myk Taylor 2022-09-18 08:19:56 -07:00
parent 215a5b0a24
commit 1f15e4d47e
No known key found for this signature in database
1 changed files with 8 additions and 3 deletions

@ -1523,6 +1523,12 @@ static int gui_getDwarfmodeViewDims(lua_State *state)
return 1; return 1;
} }
static int gui_getMousePos(lua_State *L)
{
Lua::PushPosXYZ(L, Gui::getMousePos());
return 3;
}
static const LuaWrapper::FunctionReg dfhack_gui_module[] = { static const LuaWrapper::FunctionReg dfhack_gui_module[] = {
WRAPM(Gui, getCurViewscreen), WRAPM(Gui, getCurViewscreen),
WRAPM(Gui, getFocusString), WRAPM(Gui, getFocusString),
@ -1555,6 +1561,7 @@ static const LuaWrapper::FunctionReg dfhack_gui_module[] = {
static const luaL_Reg dfhack_gui_funcs[] = { static const luaL_Reg dfhack_gui_funcs[] = {
{ "getDwarfmodeViewDims", gui_getDwarfmodeViewDims }, { "getDwarfmodeViewDims", gui_getDwarfmodeViewDims },
{ "getMousePos", gui_getMousePos },
{ NULL, NULL } { NULL, NULL }
}; };
@ -2282,9 +2289,7 @@ static const LuaWrapper::FunctionReg dfhack_screen_module[] = {
static int screen_getMousePos(lua_State *L) static int screen_getMousePos(lua_State *L)
{ {
auto pos = Screen::getMousePos(); Lua::PushPosXY(L, Screen::getMousePos());
lua_pushinteger(L, pos.x);
lua_pushinteger(L, pos.y);
return 2; return 2;
} }