diff options
Diffstat (limited to 'src/client/lua_api/scene')
| -rw-r--r-- | src/client/lua_api/scene/igeneric.cpp | 18 | ||||
| -rw-r--r-- | src/client/lua_api/scene/ilight.cpp | 23 |
2 files changed, 38 insertions, 3 deletions
diff --git a/src/client/lua_api/scene/igeneric.cpp b/src/client/lua_api/scene/igeneric.cpp index 63bf4bc..dcac022 100644 --- a/src/client/lua_api/scene/igeneric.cpp +++ b/src/client/lua_api/scene/igeneric.cpp @@ -161,6 +161,23 @@ int iscenesetscale(lua_State *L){ } /*** +Sets the visibility of this scene element +@function iscenenode:setvisible(bool) +@tparam boolean visible Sets the visibility for this element +*/ +//setvisible(true|false) +int iscenesetvisible(lua_State *L){ + int visible = lua_toboolean(L,-1); + lua_pop(L,1); + lua_getfield(L, -1, "node"); + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1);//{node=ud_ISceneNode}, ud_ISceneNode + lua_pop(L,2); + + i->setVisible(visible == 1); + return 0; +} + +/*** Get the scale of this scene element. @function iscenenode:getscale() @treturn vector3d The scale scale of this element. @@ -208,5 +225,6 @@ extern const luaL_reg igeneric_m[] = { {"setscale", iscenesetscale}, {"getscale", iscenegetscale}, {"remove", isceneremove}, + {"setvisible", iscenesetvisible}, {0, 0}, }; diff --git a/src/client/lua_api/scene/ilight.cpp b/src/client/lua_api/scene/ilight.cpp index 972de83..1e292ee 100644 --- a/src/client/lua_api/scene/ilight.cpp +++ b/src/client/lua_api/scene/ilight.cpp @@ -17,6 +17,7 @@ extern "C" { #include <shared/lua_api/common.hpp> using namespace irr; +using namespace video; using namespace scene; using namespace core; @@ -27,9 +28,9 @@ static int newiscenelight(lua_State* L){ printf("Createing light!\n"); double x,y,z; popvector3d(L,&x,&y,&z);//radius - double radius = lua_tonumber(L,-1); + double radius = lua_tonumber(L,-1); lua_pop(L,1);// - + //Create the mesh ISceneManager* smgr = device->getSceneManager(); ILightSceneNode* light = smgr->addLightSceneNode(0,vector3df(x,y,z),video::SColor(1.0f,1.0f,1.0f,1.0f),(f32)radius,(s32)-1); @@ -45,11 +46,23 @@ static int newiscenelight(lua_State* L){ return 1; - } +} + +//settype(self,const) +int settype(lua_State *L){ + video::E_LIGHT_TYPE type = (video::E_LIGHT_TYPE)lua_tonumber(L,-1);//self,type + lua_pop(L,1);//self + lua_getfield(L,-1,"node");//self,ud_ILightSceneNode + ILightSceneNode *light = (ILightSceneNode*)lua_touserdata(L,-1); + lua_pop(L,2);// + light->setLightType(type); + return 0; +} static const luaL_reg ilight_m[] = { {"getpos", iscenegetpos}, {"setpos", iscenesetpos}, + {"settype", settype}, {0, 0}, }; @@ -59,6 +72,10 @@ void ilight_register(lua_State* L){ lua_pushcfunction(L,newiscenelight);//{scene},newiscenelight() lua_setfield(L,-2,"newlight");//{scene} + set_const(L,ELT_POINT); + set_const(L,ELT_SPOT); + set_const(L,ELT_DIRECTIONAL); + lua_pop(L,1);// luaL_newmetatable(L,"scene.ilight");//scene.ilight |
