Browse Source

Change: allow number type to be read with int/long

AnnulusGames 11 months ago
parent
commit
861f05010e
1 changed files with 12 additions and 0 deletions
  1. 12 0
      src/Lua/LuaValue.cs

+ 12 - 0
src/Lua/LuaValue.cs

@@ -46,6 +46,18 @@ public readonly struct LuaValue : IEquatable<LuaValue>
                     result = Unsafe.As<double, T>(ref v);
                     return true;
                 }
+                else if (t == typeof(int))
+                {
+                    var v = (int)value;
+                    result = Unsafe.As<int, T>(ref v);
+                    return true;
+                }
+                else if (t == typeof(long))
+                {
+                    var v = (long)value;
+                    result = Unsafe.As<long, T>(ref v);
+                    return true;
+                }
                 else if (t == typeof(object))
                 {
                     result = (T)(object)value;