diff options
author | Kahrl <kahrl@gmx.net> | 2016-02-08 22:20:04 +0100 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2016-02-11 04:22:58 +0000 |
commit | b1428ab4bb1e2cf73bc8ac951d41d22203ea68a0 (patch) | |
tree | 6cc3abacb6afef178ead78405277ae161e31c7dd /src/script | |
parent | 47464c9344a1a4817ad6e4c6ec44526df305b1f6 (diff) | |
download | minetest-b1428ab4bb1e2cf73bc8ac951d41d22203ea68a0.tar.gz minetest-b1428ab4bb1e2cf73bc8ac951d41d22203ea68a0.tar.bz2 minetest-b1428ab4bb1e2cf73bc8ac951d41d22203ea68a0.zip |
Add '/clearobjects quick'
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_env.cpp | 18 | ||||
-rw-r--r-- | src/script/lua_api/l_env.h | 2 |
2 files changed, 18 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; } diff --git a/src/script/lua_api/l_env.h b/src/script/lua_api/l_env.h index 424556d4b..4f8dfcd3c 100644 --- a/src/script/lua_api/l_env.h +++ b/src/script/lua_api/l_env.h @@ -170,6 +170,8 @@ private: public: static void Initialize(lua_State *L, int top); + + static struct EnumString es_ClearObjectsMode[]; }; class LuaABM : public ActiveBlockModifier { |