Browse Source

Fix: math.pi, huge

AnnulusGames 1 year ago
parent
commit
d562bdf6c0
1 changed files with 6 additions and 5 deletions
  1. 6 5
      src/Lua/Standard/OpenLibExtensions.cs

+ 6 - 5
src/Lua/Standard/OpenLibExtensions.cs

@@ -109,16 +109,17 @@ public static class OpenLibExtensions
     public static void OpenMathLibrary(this LuaState state)
     {
         state.Environment[RandomFunction.RandomInstanceKey] = new LuaUserData<Random>(new Random());
-        state.Environment["pi"] = Math.PI;
-        state.Environment["huge"] = double.PositiveInfinity;
 
-        var table = new LuaTable(0, mathFunctions.Length);
+        var math = new LuaTable(0, mathFunctions.Length);
         foreach (var func in mathFunctions)
         {
-            table[func.Name] = func;
+            math[func.Name] = func;
         }
 
-        state.Environment["math"] = table;
+        math["pi"] = Math.PI;
+        math["huge"] = double.PositiveInfinity;
+
+        state.Environment["math"] = math;
     }
 
     public static void OpenModuleLibrary(this LuaState state)