mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 23:42:58 +02:00
CLuaInstMisc: Add getTimeOfDay() script function
- Set Lua api version to 1.39
This commit is contained in:
@@ -4,4 +4,4 @@
|
|||||||
* to luainstance.h changes
|
* to luainstance.h changes
|
||||||
*/
|
*/
|
||||||
#define LUA_API_VERSION_MAJOR 1
|
#define LUA_API_VERSION_MAJOR 1
|
||||||
#define LUA_API_VERSION_MINOR 38
|
#define LUA_API_VERSION_MINOR 39
|
||||||
|
@@ -71,6 +71,7 @@ void CLuaInstMisc::LuaMiscRegister(lua_State *L)
|
|||||||
{ "GetRevision", CLuaInstMisc::GetRevision },
|
{ "GetRevision", CLuaInstMisc::GetRevision },
|
||||||
{ "checkVersion", CLuaInstMisc::checkVersion },
|
{ "checkVersion", CLuaInstMisc::checkVersion },
|
||||||
{ "postMsg", CLuaInstMisc::postMsg },
|
{ "postMsg", CLuaInstMisc::postMsg },
|
||||||
|
{ "getTimeOfDay", CLuaInstMisc::getTimeOfDay },
|
||||||
{ "__gc", CLuaInstMisc::MiscDelete },
|
{ "__gc", CLuaInstMisc::MiscDelete },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
@@ -338,6 +339,20 @@ int CLuaInstMisc::postMsg(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CLuaInstMisc::getTimeOfDay(lua_State *L)
|
||||||
|
{
|
||||||
|
CLuaMisc *D = MiscCheckData(L, 1);
|
||||||
|
if (!D) return 0;
|
||||||
|
|
||||||
|
struct timeval t1;
|
||||||
|
double dt;
|
||||||
|
gettimeofday(&t1, NULL);
|
||||||
|
dt = (double)t1.tv_sec + ((double)t1.tv_usec)/1000000ULL;
|
||||||
|
|
||||||
|
lua_pushnumber(L, (lua_Number)dt);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int CLuaInstMisc::MiscDelete(lua_State *L)
|
int CLuaInstMisc::MiscDelete(lua_State *L)
|
||||||
{
|
{
|
||||||
CLuaMisc *D = MiscCheckData(L, 1);
|
CLuaMisc *D = MiscCheckData(L, 1);
|
||||||
|
@@ -63,6 +63,7 @@ class CLuaInstMisc
|
|||||||
static int GetRevision(lua_State *L);
|
static int GetRevision(lua_State *L);
|
||||||
static int checkVersion(lua_State *L);
|
static int checkVersion(lua_State *L);
|
||||||
static int postMsg(lua_State *L);
|
static int postMsg(lua_State *L);
|
||||||
|
static int getTimeOfDay(lua_State *L);
|
||||||
static int MiscDelete(lua_State *L);
|
static int MiscDelete(lua_State *L);
|
||||||
|
|
||||||
static void miscFunctionDeprecated(lua_State *L, std::string oldFunc);
|
static void miscFunctionDeprecated(lua_State *L, std::string oldFunc);
|
||||||
|
Reference in New Issue
Block a user