diff options
Diffstat (limited to 'src/client/lua_api/video')
| -rw-r--r-- | src/client/lua_api/video/smaterial.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/client/lua_api/video/smaterial.cpp b/src/client/lua_api/video/smaterial.cpp index e5b9eff..c72d4ca 100644 --- a/src/client/lua_api/video/smaterial.cpp +++ b/src/client/lua_api/video/smaterial.cpp @@ -10,18 +10,48 @@ extern "C" { using namespace irr::video; /*This probably needs a _gc metamethod*/ +//newsmaterial() int newsmaterial(lua_State* L){ + SMaterial* mat = new SMaterial(); - lua_pushlightuserdata(L,mat); + lua_pushlightuserdata(L,mat);//ud_smaterial + + luaL_getmetatable(L,"smaterial");//ud_smaterial,{m_smaterial} + lua_setmetatable(L,-2);//ud_smaterial + return 1; +} + +//setMaterial(self,int_num,{ITexture texture}) +int setTexture(lua_State* L){ + ITexture* tex = (ITexture*)lua_touserdata(L,-1); + lua_pop(L,1); + double num = lua_tonumber(L,-1); + lua_pop(L,1); + SMaterial* self = (SMaterial*)lua_touserdata(L,-1); + lua_pop(L,1); return 0; } +static const luaL_reg smaterial_m[] = { + {"setTexture", setTexture}, + {0,0}, +}; + #define set_const(l,x) lua_pushstring(l,#x);lua_pushinteger(l,x);lua_settable(l,-3); void smaterial_register(lua_State* L){ //Add globals dealing with material flags + luaL_newmetatable(L,"smaterial");//{m_smaterial} + + lua_newtable(L);//{m_smaterial},{} + luaL_register(L,NULL,smaterial_m);//{m_smaterial},{smaterial} + + lua_setfield(L,-2,"__index");//{m_smaterial} + + lua_pop(L,1);// + lua_getglobal(L,"video");//{} set_const(L,EMF_WIREFRAME); @@ -46,6 +76,8 @@ void smaterial_register(lua_State* L){ set_const(L,EMF_POLYGON_OFFSET); lua_pushcfunction(L,newsmaterial);//{},newsmaterial - lua_setfield(L,-2,"newsmaterial"); + lua_setfield(L,-2,"newsmaterial");//{} + + lua_pop(L,1);// } |
