diff --git a/Capy64/Runtime/Libraries/Timer.cs b/Capy64/Runtime/Libraries/Timer.cs index 63f1811..144cbfe 100644 --- a/Capy64/Runtime/Libraries/Timer.cs +++ b/Capy64/Runtime/Libraries/Timer.cs @@ -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; + } }