From b1428ab4bb1e2cf73bc8ac951d41d22203ea68a0 Mon Sep 17 00:00:00 2001 From: Kahrl Date: Mon, 8 Feb 2016 22:20:04 +0100 Subject: Add '/clearobjects quick' --- src/script/lua_api/l_env.cpp | 18 ++++++++++++++++-- src/script/lua_api/l_env.h | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src/script') 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 { -- cgit v1.2.3