From 8334100fe1b1bb40bfebff9ec9780c18fe3fd0c7 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sat, 27 Dec 2014 23:09:36 -0500 Subject: LuaVoxelManip: Add option to allocate blank data --- src/script/lua_api/l_env.cpp | 7 +++++++ src/script/lua_api/l_vmanip.cpp | 18 ++++++++++++++++++ src/script/lua_api/l_vmanip.h | 4 +++- 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'src/script') diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 3d2e20424..9e713b9b8 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -638,6 +638,13 @@ int ModApiEnvMod::l_get_voxel_manip(lua_State *L) Map *map = &(env->getMap()); LuaVoxelManip *o = new LuaVoxelManip(map); + if (lua_istable(L, 1) && lua_istable(L, 2)) { + v3s16 p1 = getNodeBlockPos(read_v3s16(L, 1)); + v3s16 p2 = getNodeBlockPos(read_v3s16(L, 2)); + sortBoxVerticies(p1, p2); + o->vm->initializeBlank(p1, p2); + } + *(void **)(lua_newuserdata(L, sizeof(void *))) = o; luaL_getmetatable(L, "VoxelManip"); lua_setmetatable(L, -2); diff --git a/src/script/lua_api/l_vmanip.cpp b/src/script/lua_api/l_vmanip.cpp index 554a57343..fb52aa21a 100644 --- a/src/script/lua_api/l_vmanip.cpp +++ b/src/script/lua_api/l_vmanip.cpp @@ -345,6 +345,16 @@ int LuaVoxelManip::l_was_modified(lua_State *L) return 1; } +int LuaVoxelManip::l_get_emerged_area(lua_State *L) +{ + LuaVoxelManip *o = checkobject(L, 1); + + push_v3s16(L, o->vm->m_area.MinEdge); + push_v3s16(L, o->vm->m_area.MaxEdge); + + return 2; +} + LuaVoxelManip::LuaVoxelManip(ManualMapVoxelManipulator *mmvm, bool is_mg_vm) { this->vm = mmvm; @@ -376,6 +386,13 @@ int LuaVoxelManip::create_object(lua_State *L) Map *map = &(env->getMap()); LuaVoxelManip *o = new LuaVoxelManip(map); + if (lua_istable(L, 1) && lua_istable(L, 2)) { + v3s16 p1 = getNodeBlockPos(read_v3s16(L, 1)); + v3s16 p2 = getNodeBlockPos(read_v3s16(L, 2)); + sortBoxVerticies(p1, p2); + o->vm->initializeBlank(p1, p2); + } + *(void **)(lua_newuserdata(L, sizeof(void *))) = o; luaL_getmetatable(L, className); lua_setmetatable(L, -2); @@ -440,5 +457,6 @@ const luaL_reg LuaVoxelManip::methods[] = { luamethod(LuaVoxelManip, get_param2_data), luamethod(LuaVoxelManip, set_param2_data), luamethod(LuaVoxelManip, was_modified), + luamethod(LuaVoxelManip, get_emerged_area), {0,0} }; diff --git a/src/script/lua_api/l_vmanip.h b/src/script/lua_api/l_vmanip.h index 608b55556..ead6efbc4 100644 --- a/src/script/lua_api/l_vmanip.h +++ b/src/script/lua_api/l_vmanip.h @@ -33,7 +33,6 @@ class ManualMapVoxelManipulator; */ class LuaVoxelManip : public ModApiBase { private: - ManualMapVoxelManipulator *vm; std::map modified_blocks; bool is_mapgen_vm; @@ -62,8 +61,11 @@ private: static int l_set_param2_data(lua_State *L); static int l_was_modified(lua_State *L); + static int l_get_emerged_area(lua_State *L); public: + ManualMapVoxelManipulator *vm; + LuaVoxelManip(ManualMapVoxelManipulator *mmvm, bool is_mapgen_vm); LuaVoxelManip(Map *map); ~LuaVoxelManip(); -- cgit v1.2.3