aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew I <matttpt@gmail.com>2012-07-28 15:27:31 -0400
committerPerttu Ahola <celeron55@gmail.com>2012-08-12 16:44:55 +0300
commit548da26ddc1e38bffbc05c5577fe9a60476f8e71 (patch)
tree6b12fa69b4b0fc2097bcb66c1642ef5077200be3 /src
parent8e0ac70c4ddfffedcd9e85b409360b4356d033c4 (diff)
downloadminetest-548da26ddc1e38bffbc05c5577fe9a60476f8e71.tar.gz
minetest-548da26ddc1e38bffbc05c5577fe9a60476f8e71.tar.bz2
minetest-548da26ddc1e38bffbc05c5577fe9a60476f8e71.zip
Extend Lua API in order to implement chat commands
minetest.get_server_status() minetest.request_shutdown() EnvRef:clear_objects()
Diffstat (limited to 'src')
-rw-r--r--src/scriptapi.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index a1975971f..a6eaabf97 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -3810,6 +3810,15 @@ private:
return 1;
}
+ // EnvRef:clear_objects()
+ // clear all objects in the environment
+ static int l_clear_objects(lua_State *L)
+ {
+ EnvRef *o = checkobject(L, 1);
+ o->m_env->clearAllObjects();
+ return 0;
+ }
+
public:
EnvRef(ServerEnvironment *env):
m_env(env)
@@ -3891,6 +3900,7 @@ const luaL_reg EnvRef::methods[] = {
method(EnvRef, find_node_near),
method(EnvRef, find_nodes_in_area),
method(EnvRef, get_perlin),
+ method(EnvRef, clear_objects),
{0,0}
};
@@ -4170,6 +4180,20 @@ static int l_log(lua_State *L)
return 0;
}
+// request_shutdown()
+static int l_request_shutdown(lua_State *L)
+{
+ get_server(L)->requestShutdown();
+ return 0;
+}
+
+// get_server_status()
+static int l_get_server_status(lua_State *L)
+{
+ lua_pushstring(L, wide_to_narrow(get_server(L)->getStatusString()).c_str());
+ return 1;
+}
+
// register_item_raw({lots of stuff})
static int l_register_item_raw(lua_State *L)
{
@@ -4911,6 +4935,8 @@ static int l_rollback_revert_actions_by(lua_State *L)
static const struct luaL_Reg minetest_f [] = {
{"debug", l_debug},
{"log", l_log},
+ {"request_shutdown", l_request_shutdown},
+ {"get_server_status", l_get_server_status},
{"register_item_raw", l_register_item_raw},
{"register_alias_raw", l_register_alias_raw},
{"register_craft", l_register_craft},