This function was working in the production system and I'm not aware of changing anything (MikTeX did some package updates which may have had an effect).
A very much stripped down MWE is
\documentclass{article}
\directlua{
function underscore(s)
s = tostring(s+2080)
tex.print(s)
end
}
\DeclareRobustCommand{\Binl}[1]{\directlua{underscore([[#1]])}}%
\begin{document}
Use M\Binl{1} or M\Binl{2}
\end{document}
I used to get M_1 and M_2 with proper subscripts, but now the correct unicode characters U+2081 and U+2082 are being generated but have acquired a trailing ".0" as can be seen in the output. N.B. I've omitted prepending "\char\"" to s before passing the string back.
Output :
Use M2081.0 or M2082.0