aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_env.cpp
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2013-09-08 10:54:36 +0200
committerSfan5 <sfan5@live.de>2013-09-08 11:09:50 +0200
commit6291fd1cbb9c2808e336532c833e26330ff2642b (patch)
treea1cf96776a56f2154daaacee6533b2a436b7ff4c /src/script/lua_api/l_env.cpp
parent4a2203413fbd4e4ff7e801172416ae8012e861d4 (diff)
downloadminetest-6291fd1cbb9c2808e336532c833e26330ff2642b.tar.gz
minetest-6291fd1cbb9c2808e336532c833e26330ff2642b.tar.bz2
minetest-6291fd1cbb9c2808e336532c833e26330ff2642b.zip
Add minetest.get_gametime() API function, that returns the number of seconds since the world was created.
Diffstat (limited to 'src/script/lua_api/l_env.cpp')
-rw-r--r--src/script/lua_api/l_env.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index dbaf6fb36..8b0d8cd6e 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -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);