From 96da001734a452505f3e8e109e3a605cee9ddb88 Mon Sep 17 00:00:00 2001 From: mid <> Date: Sun, 27 Jul 2025 16:54:32 +0300 Subject: [PATCH] Add game.ui.obj --- src/luaapi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/luaapi.c b/src/luaapi.c index e8b3de9..74db793 100644 --- a/src/luaapi.c +++ b/src/luaapi.c @@ -1332,6 +1332,7 @@ static int game_camfocus(lua_State *L) { #define MENUITEM_LABEL 1 #define MENUITEM_TEXTBUTTON 2 #define MENUITEM_TEXTINPUT 3 +#define MENUITEM_OBJ 4 struct menuitem { int type; struct k3MObj *ptr; @@ -2021,6 +2022,14 @@ static int dagame_send(lua_State *L) { return 0; } +static int dagame_ui_obj(lua_State *L) { + struct menuitem *item = lua_newuserdata(L, sizeof(*item)); + item->type = MENUITEM_OBJ; + item->ptr = (void*) k3MObj(); + luaL_setmetatable(L, "k3menuitem"); + return 1; +} + static int dagame_ui_screen(lua_State *L) { struct menuitem *item = lua_newuserdata(L, sizeof(*item)); item->type = MENUITEM_SCREEN; @@ -2923,6 +2932,9 @@ void luaapi_init() { k3Log(k3_DEBUG, "Creating table game.ui"); lua_newtable(L); + lua_pushcfunction(L, dagame_ui_obj); + lua_setfield(L, -2, "obj"); + lua_pushcfunction(L, dagame_ui_screen); lua_setfield(L, -2, "screen");