SAPI: Move core.get_us_time() to Util module
authorkwolekr <kwolekr@minetest.net>
Mon, 26 Oct 2015 07:45:55 +0000 (03:45 -0400)
committerkwolekr <kwolekr@minetest.net>
Mon, 26 Oct 2015 07:46:36 +0000 (03:46 -0400)
doc/menu_lua_api.txt
src/script/lua_api/l_env.cpp
src/script/lua_api/l_env.h
src/script/lua_api/l_util.cpp
src/script/lua_api/l_util.h

index d1e209187756156f6b17835a24fe74986b015a09..c995b4c5595e153cec4542edeaf455a18bb086fe 100644 (file)
@@ -191,6 +191,8 @@ core.create_world(worldname, gameid)
 core.delete_world(index)
 
 Helpers:
+core.get_us_time()
+^ returns time with microsecond precision
 core.gettext(string) -> string
 ^ look up the translation of a string in the gettext message catalog
 fgettext_ne(string, ...)
index 2645c800721d85c2c29dc74c5f6cce33f83f818c..6ffca6f0f36d6bd1b917c786ec4cd2f55c512b83 100644 (file)
@@ -938,14 +938,6 @@ int ModApiEnvMod::l_forceload_free_block(lua_State *L)
        return 0;
 }
 
-// get_us_time()
-int ModApiEnvMod::l_get_us_time(lua_State *L)
-{
-       NO_MAP_LOCK_REQUIRED;
-       lua_pushnumber(L, porting::getTimeUs());
-       return 1;
-}
-
 void ModApiEnvMod::Initialize(lua_State *L, int top)
 {
        API_FCT(set_node);
@@ -987,5 +979,4 @@ void ModApiEnvMod::Initialize(lua_State *L, int top)
        API_FCT(transforming_liquid_add);
        API_FCT(forceload_block);
        API_FCT(forceload_free_block);
-       API_FCT(get_us_time);
 }
index 4f204da81c4bc4440b3bd7d3ec29771324ef4815..8354379f3ddaa33cf26185eb4298afab770093ca 100644 (file)
@@ -168,9 +168,6 @@ private:
        // stops forceloading a position
        static int l_forceload_free_block(lua_State *L);
 
-       // get us precision time
-       static int l_get_us_time(lua_State *L);
-
 public:
        static void Initialize(lua_State *L, int top);
 };
index d5adc7ab0aeebbdcf6bcf2598658d9e7e50cb803..3f7e15acfa79e5fd3cf9bd1934094fce41b00929 100644 (file)
@@ -65,6 +65,14 @@ int ModApiUtil::l_log(lua_State *L)
        return 0;
 }
 
+// get_us_time()
+int ModApiUtil::l_get_us_time(lua_State *L)
+{
+       NO_MAP_LOCK_REQUIRED;
+       lua_pushnumber(L, porting::getTimeUs());
+       return 1;
+}
+
 #define CHECK_SECURE_SETTING(L, name) \
        if (name.compare(0, 7, "secure.") == 0) {\
                lua_pushliteral(L, "Attempt to set secure setting.");\
@@ -368,6 +376,8 @@ void ModApiUtil::Initialize(lua_State *L, int top)
 {
        API_FCT(log);
 
+       API_FCT(get_us_time);
+
        API_FCT(setting_set);
        API_FCT(setting_get);
        API_FCT(setting_setbool);
@@ -399,6 +409,8 @@ void ModApiUtil::InitializeAsync(AsyncEngine& engine)
 {
        ASYNC_API_FCT(log);
 
+       ASYNC_API_FCT(get_us_time);
+
        //ASYNC_API_FCT(setting_set);
        ASYNC_API_FCT(setting_get);
        //ASYNC_API_FCT(setting_setbool);
index 4b55b19667596fd39f416cd82711c2536808b810..68c24520c8edfd505cb93ce182b0f59c60be2ab8 100644 (file)
@@ -41,6 +41,9 @@ private:
        // The two-argument version accept a log level: error, action, info, or verbose.
        static int l_log(lua_State *L);
 
+       // get us precision time
+       static int l_get_us_time(lua_State *L);
+
        // setting_set(name, value)
        static int l_setting_set(lua_State *L);