Browse Source

Fix: LuaTable

AnnulusGames 1 year ago
parent
commit
e068af787f
1 changed files with 7 additions and 11 deletions
  1. 7 11
      src/Lua/LuaTable.cs

+ 7 - 11
src/Lua/LuaTable.cs

@@ -57,20 +57,13 @@ public sealed class LuaTable
                 }
             }
 
-            if (value.Type is LuaValueType.Nil)
-            {
-                dictionary.Remove(key);
-            }
-            else
-            {
-                dictionary[key] = value;
-            }
+            dictionary[key] = value;
         }
     }
 
     public int HashMapCount
     {
-        get => dictionary.Count;
+        get => dictionary.Count(x => x.Value.Type is not LuaValueType.Nil);
     }
 
     public int ArrayLength
@@ -189,8 +182,11 @@ public sealed class LuaTable
 
             foreach (var kv in dictionary)
             {
-                pair = kv;
-                return true;
+                if (kv.Value.Type is not LuaValueType.Nil)
+                {
+                    pair = kv;
+                    return true;
+                }
             }
         }
         else