8

When there is \directlua{x = 25} one can say \edef\rgf{\directlua{tex.sprint(x)}}, but when x was never created by \directlua{x = 25}, \directlua{tex.sprint(x)} will fail. Thus something like \@ifundefined{x}{x undefined}{x defined} would be nice. How does one "say this in Lua", please?

Stephen
  • 14,890

1 Answers1

12

You can do this:

\directlua{tex.sprint( x or 42 ) }

or perhaps

\directlua{
  if x then
    tex.sprint(x)
  % else
    % do something else
  end
}
topskip
  • 37,020