diff options
author | kwolekr <kwolekr@minetest.net> | 2014-01-19 02:55:34 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2014-01-19 02:55:59 -0500 |
commit | bafc4ac6a109525b071e160fa3fe74a344a57c68 (patch) | |
tree | 1437bc6652eecc078be4693b338561b29710dc69 | |
parent | 21c96249fa6e9d4c65b4d897d4b6e2f48371e620 (diff) | |
download | minetest-bafc4ac6a109525b071e160fa3fe74a344a57c68.tar.gz minetest-bafc4ac6a109525b071e160fa3fe74a344a57c68.tar.bz2 minetest-bafc4ac6a109525b071e160fa3fe74a344a57c68.zip |
LuaVoxelManip: Add get_param2_data and set_param2_data
-rw-r--r-- | src/script/lua_api/l_vmanip.cpp | 44 | ||||
-rw-r--r-- | src/script/lua_api/l_vmanip.h | 3 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/script/lua_api/l_vmanip.cpp b/src/script/lua_api/l_vmanip.cpp index 92c04db3a..4c9047bd9 100644 --- a/src/script/lua_api/l_vmanip.cpp +++ b/src/script/lua_api/l_vmanip.cpp @@ -229,6 +229,48 @@ int LuaVoxelManip::l_set_light_data(lua_State *L) return 0; } +int LuaVoxelManip::l_get_param2_data(lua_State *L) +{ + NO_MAP_LOCK_REQUIRED; + + LuaVoxelManip *o = checkobject(L, 1); + ManualMapVoxelManipulator *vm = o->vm; + + int volume = vm->m_area.getVolume(); + + lua_newtable(L); + for (int i = 0; i != volume; i++) { + lua_Integer param2 = vm->m_data[i].param2; + lua_pushinteger(L, param2); + lua_rawseti(L, -2, i + 1); + } + + return 1; +} + +int LuaVoxelManip::l_set_param2_data(lua_State *L) +{ + NO_MAP_LOCK_REQUIRED; + + LuaVoxelManip *o = checkobject(L, 1); + ManualMapVoxelManipulator *vm = o->vm; + + if (!lua_istable(L, 2)) + return 0; + + int volume = vm->m_area.getVolume(); + for (int i = 0; i != volume; i++) { + lua_rawgeti(L, 2, i + 1); + u8 param2 = lua_tointeger(L, -1); + + vm->m_data[i].param2 = param2; + + lua_pop(L, 1); + } + + return 0; +} + int LuaVoxelManip::l_update_map(lua_State *L) { LuaVoxelManip *o = checkobject(L, 1); @@ -352,5 +394,7 @@ const luaL_reg LuaVoxelManip::methods[] = { luamethod(LuaVoxelManip, set_lighting), luamethod(LuaVoxelManip, get_light_data), luamethod(LuaVoxelManip, set_light_data), + luamethod(LuaVoxelManip, get_param2_data), + luamethod(LuaVoxelManip, set_param2_data), {0,0} }; diff --git a/src/script/lua_api/l_vmanip.h b/src/script/lua_api/l_vmanip.h index b3393e09a..fc7ef30e6 100644 --- a/src/script/lua_api/l_vmanip.h +++ b/src/script/lua_api/l_vmanip.h @@ -55,6 +55,9 @@ private: static int l_get_light_data(lua_State *L); static int l_set_light_data(lua_State *L); + static int l_get_param2_data(lua_State *L); + static int l_set_param2_data(lua_State *L); + public: LuaVoxelManip(ManualMapVoxelManipulator *mmvm, bool is_mapgen_vm); LuaVoxelManip(Map *map); |