aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/lua_api/gui')
-rw-r--r--src/client/lua_api/gui/iguibutton.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/client/lua_api/gui/iguibutton.cpp b/src/client/lua_api/gui/iguibutton.cpp
index 2d04fd1..0e16ef6 100644
--- a/src/client/lua_api/gui/iguibutton.cpp
+++ b/src/client/lua_api/gui/iguibutton.cpp
@@ -30,31 +30,33 @@ static int newiguibutton(lua_State* L){
int nargs = lua_gettop(L);
IGUIElement* parent = NULL;
- if(nargs == 4){
+ if(nargs == 3){
+ lua_getfield(L,-1,"guielement");
parent = (IGUIElement*)lua_touserdata(L,-1);
- lua_pop(L,1);
+ lua_pop(L,2);//{{sx,sy},{ex,ey}},"text"
}
-
- const char* label_c = lua_tostring(L,-1);
- const wchar_t* label_w = irr::core::stringw(label_c).c_str();
- lua_pop(L,1);
-
+ const char* label_c = lua_tostring(L,-1);//{{sx,sy},{ex,ey}},"text"
+ const wchar_t* label_w = irr::core::stringw(label_c).c_str();//{{sx,sy},{ex,ey}},"text"
+ lua_pop(L,1);//{{sx,sy},{ex,ey}}
+ printf("Created title\n");
long sx,sy,ex,ey;
- poprecti(L,&sx,&sy,&ex,&ey);
+ poprecti(L,&sx,&sy,&ex,&ey);//
+ printf("Got coords\n");
rect<s32> dim = rect<s32>(sx,sy,ex,ey);
IGUIEnvironment* env = device->getGUIEnvironment();
- IGUIButton* but = env->addButton(dim,parent,-2,label_w,L"");
+ IGUIButton* but = env->addButton(dim,parent,-1,label_w,L"");
+ printf("Added button\n");
lua_newtable(L);//{}
lua_pushlightuserdata(L,but);//{},ud_iguibutton
lua_setfield(L,-2,"guielement");//{guielement}
luaL_getmetatable(L,"gui.iguibutton");//{guielement},{m_iguibutton}
lua_setmetatable(L,-2);//{guielement}
+ printf("Created lua representation\n");
setelementcallback(L,EGET_BUTTON_CLICKED,"onClicked");//
-
printf("Finished registering callback\n");
return 1;