Browse Source

Merge pull request #289 from Librelancer/fix_os_clock

Fix OsTimeModule.clock returning nil at application start
Kevin Morgan 4 years ago
parent
commit
65e4bd1550
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/MoonSharp.Interpreter/CoreLib/OsTimeModule.cs

+ 3 - 1
src/MoonSharp.Interpreter/CoreLib/OsTimeModule.cs

@@ -35,7 +35,9 @@ namespace MoonSharp.Interpreter.CoreLib
 		[MoonSharpModuleMethod]
 		public static DynValue clock(ScriptExecutionContext executionContext, CallbackArguments args)
 		{
-			return GetUnixTime(DateTime.UtcNow, Time0);
+			var t = GetUnixTime(DateTime.UtcNow, Time0);
+			if (t.IsNil()) return DynValue.NewNumber(0.0);
+			return t;
 		}
 
 		[MoonSharpModuleMethod]