aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_env.cpp
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2016-02-08 22:20:04 +0100
committerparamat <mat.gregory@virginmedia.com>2016-02-11 04:22:58 +0000
commitb1428ab4bb1e2cf73bc8ac951d41d22203ea68a0 (patch)
tree6cc3abacb6afef178ead78405277ae161e31c7dd /src/script/lua_api/l_env.cpp
parent47464c9344a1a4817ad6e4c6ec44526df305b1f6 (diff)
downloadminetest-b1428ab4bb1e2cf73bc8ac951d41d22203ea68a0.tar.gz
minetest-b1428ab4bb1e2cf73bc8ac951d41d22203ea68a0.tar.bz2
minetest-b1428ab4bb1e2cf73bc8ac951d41d22203ea68a0.zip
Add '/clearobjects quick'
Diffstat (limited to 'src/script/lua_api/l_env.cpp')
-rw-r--r--src/script/lua_api/l_env.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index 084b1b440..b445b1eb9 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -36,6 +36,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "emerge.h"
#include "pathfinder.h"
+struct EnumString ModApiEnvMod::es_ClearObjectsMode[] =
+{
+ {CLEAR_OBJECTS_MODE_FULL, "full"},
+ {CLEAR_OBJECTS_MODE_QUICK, "quick"},
+ {0, NULL},
+};
+
///////////////////////////////////////////////////////////////////////////////
@@ -727,13 +734,20 @@ int ModApiEnvMod::l_get_voxel_manip(lua_State *L)
return 1;
}
-// clear_objects()
+// clear_objects([options])
// clear all objects in the environment
+// where options = {mode = "full" or "quick"}
int ModApiEnvMod::l_clear_objects(lua_State *L)
{
GET_ENV_PTR;
- env->clearAllObjects();
+ ClearObjectsMode mode = CLEAR_OBJECTS_MODE_FULL;
+ if (lua_istable(L, 1)) {
+ mode = (ClearObjectsMode)getenumfield(L, 1, "mode",
+ ModApiEnvMod::es_ClearObjectsMode, mode);
+ }
+
+ env->clearObjects(mode);
return 0;
}