1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add minetest.get_gametime() API function, that returns the number of seconds since the world was created.

This commit is contained in:
Novatux 2013-09-08 10:54:36 +02:00 committed by Sfan5
parent 4a2203413f
commit 6291fd1cbb
3 changed files with 15 additions and 0 deletions

View file

@ -476,6 +476,16 @@ int ModApiEnvMod::l_get_timeofday(lua_State *L)
return 1;
}
// minetest.get_gametime()
int ModApiEnvMod::l_get_gametime(lua_State *L)
{
GET_ENV_PTR;
int game_time = env->getGameTime();
lua_pushnumber(L, game_time);
return 1;
}
// minetest.find_node_near(pos, radius, nodenames) -> pos or nil
// nodenames: eg. {"ignore", "group:tree"} or "default:dirt"
@ -793,6 +803,7 @@ void ModApiEnvMod::Initialize(lua_State *L, int top)
API_FCT(get_objects_inside_radius);
API_FCT(set_timeofday);
API_FCT(get_timeofday);
API_FCT(get_gametime);
API_FCT(find_node_near);
API_FCT(find_nodes_in_area);
API_FCT(get_perlin);

View file

@ -104,6 +104,9 @@ private:
// minetest.get_timeofday() -> 0...1
static int l_get_timeofday(lua_State *L);
// minetest.get_gametime()
static int l_get_gametime(lua_State *L);
// minetest.find_node_near(pos, radius, nodenames) -> pos or nil
// nodenames: eg. {"ignore", "group:tree"} or "default:dirt"
static int l_find_node_near(lua_State *L);