1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-22 23:58:48 -05:00

Extend Lua API in order to implement chat commands

minetest.get_server_status()
minetest.request_shutdown()
EnvRef:clear_objects()
This commit is contained in:
Matthew I 2012-07-28 15:27:31 -04:00 committed by Perttu Ahola
parent 8e0ac70c4d
commit 548da26ddc
2 changed files with 32 additions and 0 deletions

View File

@ -928,6 +928,10 @@ minetest.after(time, func, param)
^ Call function after time seconds ^ Call function after time seconds
^ param is optional; to pass multiple parameters, pass a table. ^ param is optional; to pass multiple parameters, pass a table.
Server:
minetest.request_shutdown() -> request for server shutdown
minetest.get_server_status() -> server status string
Random: Random:
minetest.get_connected_players() -> list of ObjectRefs minetest.get_connected_players() -> list of ObjectRefs
minetest.hash_node_position({x=,y=,z=}) -> 48-bit integer minetest.hash_node_position({x=,y=,z=}) -> 48-bit integer
@ -1017,6 +1021,8 @@ methods:
^ nodenames: eg. {"ignore", "group:tree"} or "default:dirt" ^ nodenames: eg. {"ignore", "group:tree"} or "default:dirt"
- get_perlin(seeddiff, octaves, persistence, scale) - get_perlin(seeddiff, octaves, persistence, scale)
^ Return world-specific perlin noise (int(worldseed)+seeddiff) ^ Return world-specific perlin noise (int(worldseed)+seeddiff)
- clear_objects()
^ clear all objects in the environments
Deprecated: Deprecated:
- add_rat(pos): Add C++ rat object (no-op) - add_rat(pos): Add C++ rat object (no-op)
- add_firefly(pos): Add C++ firefly object (no-op) - add_firefly(pos): Add C++ firefly object (no-op)

View File

@ -3810,6 +3810,15 @@ private:
return 1; 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: public:
EnvRef(ServerEnvironment *env): EnvRef(ServerEnvironment *env):
m_env(env) m_env(env)
@ -3891,6 +3900,7 @@ const luaL_reg EnvRef::methods[] = {
method(EnvRef, find_node_near), method(EnvRef, find_node_near),
method(EnvRef, find_nodes_in_area), method(EnvRef, find_nodes_in_area),
method(EnvRef, get_perlin), method(EnvRef, get_perlin),
method(EnvRef, clear_objects),
{0,0} {0,0}
}; };
@ -4170,6 +4180,20 @@ static int l_log(lua_State *L)
return 0; 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}) // register_item_raw({lots of stuff})
static int l_register_item_raw(lua_State *L) 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 [] = { static const struct luaL_Reg minetest_f [] = {
{"debug", l_debug}, {"debug", l_debug},
{"log", l_log}, {"log", l_log},
{"request_shutdown", l_request_shutdown},
{"get_server_status", l_get_server_status},
{"register_item_raw", l_register_item_raw}, {"register_item_raw", l_register_item_raw},
{"register_alias_raw", l_register_alias_raw}, {"register_alias_raw", l_register_alias_raw},
{"register_craft", l_register_craft}, {"register_craft", l_register_craft},