# \newif inside function definition in LuaTeX

In a function I have in a package I'm working on I'm trying to add the following line:

\expandafter\newif\csname ifgre@scale@#1\endcsname%

Now, this works fine under LuaLaTeX, but the package is supposed to be compatible under both LuaLaTeX and LuaTeX and when I try to compile a document in LuaTeX, I get the following error:

! Forbidden control sequence found while scanning definition of \grechangedim.
<inserted text>
}
\newif
l.828           \expandafter\newif
\csname ifgre@scale@#1\endcsname%
?

Is there a PlainTeX compatible way to create a new conditional within a function?

LuaLaTeX MWE:

\documentclass[11pt]{article}

\usepackage{testing}

\begin{document}
\grechangedim{test}
Hello.
\end{document}

LuaTeX MWE:

\pdfpagewidth210mm
\pdfpageheight297mm
\input testing-input.tex
\grechangedim{test}
Hello.
\bye

testing.sty:

% ------IDENTIFICATION------
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesPackage{testing}
% For testing package code.

% ------INITIAL CODE------

% ------DECLARATION OF OPTIONS------

% ------EXECUTION OF OPTIONS------
\ProcessOptions

% ------MAIN CODE------

\AtBeginDocument{}

\AtEndDocument{}

\input testing-input.tex

testing-input.tex:

\def\grechangedim#1{%
\expandafter\newif\csname ifgre@scale@#1\endcsname%
}
• Where is the luatex content here? – user31729 Sep 17 '15 at 18:45