Add timer.now() to get current time in milliseconds (UTC)

This commit is contained in:
Alessandro Proto 2023-02-10 20:43:58 +01:00
parent ffa223b5b3
commit 392c1b9aca

View file

@ -15,6 +15,11 @@ class Timer : IPlugin
name = "start",
function = L_StartTimer,
},
new()
{
name = "now",
function = L_Now
},
new(),
};
@ -82,4 +87,14 @@ class Timer : IPlugin
L.PushInteger(timerId);
return 1;
}
private static int L_Now(IntPtr state)
{
var now = DateTimeOffset.UtcNow;
var L = Lua.FromIntPtr(state);
L.PushInteger(now.ToUnixTimeMilliseconds());
return 1;
}
}