From f5da9002e801281a126e1de4e1844ca0d7ac5c66 Mon Sep 17 00:00:00 2001 From: Alexander M Pickering Date: Sun, 17 Sep 2023 17:02:22 -0500 Subject: Add a setimage method for iguibuttons --- src/client/lua_api/gui/iguibutton.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/client') diff --git a/src/client/lua_api/gui/iguibutton.cpp b/src/client/lua_api/gui/iguibutton.cpp index 999e667..ee5ac79 100644 --- a/src/client/lua_api/gui/iguibutton.cpp +++ b/src/client/lua_api/gui/iguibutton.cpp @@ -79,12 +79,30 @@ static int newiguibutton(lua_State* L){ return 1; } +/*** +Set the image of a button. +@function iguibutton:setimage(tex) +@tparam texture tex The texture to apply to this button. +*/ +//setimage(self, itexture) +int setimage_button(lua_State *L){ + lua_getfield(L,-1,"texture");//{self},{image},image* + video::ITexture* tex = (video::ITexture*) lua_touserdata(L,-1); + lua_pop(L,2);//{self} + lua_getfield(L,-1,"guielement");//{self},iguielement* + IGUIButton *e = (IGUIButton*)lua_touserdata(L,-1); + lua_pop(L,2);// + e->setImage(tex); + return 0; +} + static const luaL_Reg iguibutton_f[] = { {"new", newiguibutton}, {0,0}, }; static const luaL_Reg iguibutton_m[] = { + {"setimage", setimage_button}, {0,0}, }; -- cgit v1.2.3-70-g09d2