]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Add minetest.get_gametime() API function, that returns the number of seconds since...
authorNovatux <nathanael.courant@laposte.net>
Sun, 8 Sep 2013 08:54:36 +0000 (10:54 +0200)
committerSfan5 <sfan5@live.de>
Sun, 8 Sep 2013 09:09:50 +0000 (11:09 +0200)
doc/lua_api.txt
src/script/lua_api/l_env.cpp
src/script/lua_api/l_env.h

index e65392c177ea210183e0dd60a65a5bbcec05ad2f..f593b0db8d294649b80528ea25876cd2e94a979b 100644 (file)
@@ -1226,6 +1226,7 @@ minetest.get_player_by_name(name) -- Get an ObjectRef to a player
 minetest.get_objects_inside_radius(pos, radius)
 minetest.set_timeofday(val): val: 0...1; 0 = midnight, 0.5 = midday
 minetest.get_timeofday()
+minetest.get_gametime(): returns the time, in seconds, since the world was created
 minetest.find_node_near(pos, radius, nodenames) -> pos or nil
 ^ nodenames: eg. {"ignore", "group:tree"} or "default:dirt"
 minetest.find_nodes_in_area(minp, maxp, nodenames) -> list of positions
index dbaf6fb368cb1fb538f646f7da37dda17527dd80..8b0d8cd6ec506bfea9e164b9453a4607aa0120be 100644 (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);
index adb80a8a833dd7628aba62a9ff810f7cd9aaaa1d..814d12165dc5be4de55067e21a30ccddc9ce90e9 100644 (file)
@@ -104,6 +104,9 @@ class ModApiEnvMod : public ModApiBase {
        // 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);