% luaoptions support package.
%
% Copyright (C) 2015-2026 the lualatex-tools Project
% License: MIT
% This file is part of luaoptions.

\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{luaoptions}[2026/05/20 v0.9]  %%LUAOPTIONS_DATE LUAOPTIONS_VERSION

% Dependencies
\RequirePackage{luatexbase}
\RequirePackage{luaotfload}
\RequirePackage{xkeyval}

\directlua{
  lua_options = require(kpse.find_file("luaoptions.lua") or "luaoptions.lua")
}

% Set an option in a registered client
\newcommand{\setluaoption}[3]{%
  \directlua{
    lua_options.set_option(
      '\luatexluaescapestring{#1}',
      '\luatexluaescapestring{#2}',
      '\luatexluaescapestring{#3}')
  }%
}

% Use an option and directly write it to LaTeX
\newcommand{\useluaoption}[2]{%
  \directlua{
    lua_options.use_option(
      '\luatexluaescapestring{#1}',
      '\luatexluaescapestring{#2}')
  }%
}
