/// <summary> /// Remove and return the last entry in table. /// </summary> /// <param name="t"></param> /// <returns></returns> public static object remove(NativeLuaTable t) { var value = t[t.__Count()]; t[t.__Count()] = null; return(value); }
/// <summary> /// Insert value into the table at position pos /// </summary> /// <param name="t"></param> /// <param name="pos">1 based position.</param> /// <param name="value"></param> public static void insert(NativeLuaTable t, int pos, object value) { for (var i = t.__Count(); i >= pos; i--) { t[i + 1] = t[i]; } t[pos] = value; }
/// <summary> /// Return the size of the table when seen as a list /// </summary> /// <param name="t">A native lua table</param> /// <returns></returns> public static int getn(NativeLuaTable t) { if (t == null) { throw new ArgumentNullException(nameof(t)); } return(t.__Count()); }
/// <summary> /// Remove and return the table element at position pos /// </summary> /// <param name="t"></param> /// <param name="pos">1 based position</param> /// <returns></returns> public static object remove(NativeLuaTable t, int pos) { var value = t[pos]; t[pos] = null; for (var i = pos + 1; i <= t.__Count(); i++) { t[i - 1] = t[i]; t[i] = null; } return(value); }
/// <summary> /// Insert value into the table at end of table. /// </summary> /// <param name="t"></param> /// <param name="value"></param> public static void insert(NativeLuaTable t, object value) { t[t.__Count() + 1] = value; }