@@ -3613,9 +3613,7 @@ public static void insert(LuaTable t, object pos, object value)
3613
3613
/// <param name="e"></param>
3614
3614
/// <param name="t"></param>
3615
3615
public static void move ( LuaTable t1 , int f , int e , int t )
3616
- {
3617
- move ( t1 , f , e , t , t1 ) ;
3618
- } // proc move
3616
+ => move ( t1 , f , e , t , t1 ) ;
3619
3617
3620
3618
/// <summary></summary>
3621
3619
/// <param name="t1"></param>
@@ -3626,9 +3624,9 @@ public static void move(LuaTable t1, int f, int e, int t)
3626
3624
public static void move ( LuaTable t1 , int f , int e , int t , LuaTable t2 )
3627
3625
{
3628
3626
if ( f < 0 )
3629
- throw new ArgumentOutOfRangeException ( "f" ) ;
3627
+ throw new ArgumentOutOfRangeException ( nameof ( f ) ) ;
3630
3628
if ( t < 0 )
3631
- throw new ArgumentOutOfRangeException ( "t" ) ;
3629
+ throw new ArgumentOutOfRangeException ( nameof ( t ) ) ;
3632
3630
if ( f > e )
3633
3631
return ;
3634
3632
@@ -3638,6 +3636,34 @@ public static void move(LuaTable t1, int f, int e, int t, LuaTable t2)
3638
3636
3639
3637
#endregion
3640
3638
3639
+ #region -- merge --
3640
+
3641
+ /// <summary>merge the second table into the first one.</summary>
3642
+ /// <param name="targetTable"></param>
3643
+ /// <param name="mergeTable"></param>
3644
+ /// <param name="overwrite"></param>
3645
+ /// <returns></returns>
3646
+ public static LuaTable merge ( LuaTable targetTable , LuaTable mergeTable , bool overwrite = true )
3647
+ {
3648
+ foreach ( var kv in mergeTable )
3649
+ {
3650
+ if ( kv . Value is LuaTable m )
3651
+ {
3652
+ var v = targetTable [ kv . Key ] ;
3653
+ if ( v is LuaTable t )
3654
+ merge ( t , m , overwrite ) ;
3655
+ else if ( v == null || ( v != null && overwrite ) )
3656
+ targetTable [ kv . Key ] = merge ( new LuaTable ( ) , m , true ) ;
3657
+ }
3658
+ else if ( overwrite || kv . Value == null )
3659
+ targetTable [ kv . Key ] = kv . Value ;
3660
+ }
3661
+
3662
+ return targetTable ;
3663
+ } // proc merge
3664
+
3665
+ #endregion
3666
+
3641
3667
#region -- pack --
3642
3668
3643
3669
/// <summary>Returns a new table with all parameters stored into keys 1, 2, etc. and with a field "n"
0 commit comments