diff --git a/GlobalMethods.h b/GlobalMethods.h index e6e7f38..cd7b731 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -2254,5 +2254,30 @@ namespace LuaGlobalFunctions Eluna::Push(L, Player::IsBagPos((bag << 8) + slot)); return 1; } + + /** + * Returns current time in ms + * + * @return uint32 currTime + */ + int GetCurrTime(Eluna* E) + { + Eluna::Push(E->L, ElunaUtil::GetCurrTime()); + return 1; + } + + /** + * Returns difference from a [Global:GetCurrTime] time to now + * + * @param uint32 oldTime + * @return uint32 timeDiff + */ + int GetTimeDiff(Eluna* E) + { + uint32 oldtimems = Eluna::CHECKVAL(E->L, 1); + + Eluna::Push(E->L, ElunaUtil::GetTimeDiff(oldtimems)); + return 1; + } } #endif diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index 3c0e7eb..a0a84cd 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -85,6 +85,8 @@ ElunaGlobal::ElunaRegister GlobalMethods[] = { "bit_and", &LuaGlobalFunctions::bit_and }, { "GetItemLink", &LuaGlobalFunctions::GetItemLink }, { "GetMapById", &LuaGlobalFunctions::GetMapById }, + { "GetCurrTime", &LuaGlobalFunctions::GetCurrTime }, + { "GetTimeDiff", &LuaGlobalFunctions::GetTimeDiff }, // Boolean { "IsInventoryPos", &LuaGlobalFunctions::IsInventoryPos },