public static object GetMetamethod(LuaContext context, object obj, string methodName) { LuaTable table; if ((table = obj as LuaTable) != null) table = table.Metatable; else if (context != null) table = context.GetTypeMetatable(obj); return methodName == null || table == null ? null : table.GetValue(methodName); }