I would like to instead use a lua function and I think I recall having seen somewhere the use of a call like lua( ….) or lua.foo.bar() in a MetaPost/MetaFun/LMTX example but I cannot find it anymore.
Is it possible to do a lua() call from within MetaPost within LMTX and if so, what is the way to do it? This below is the state of my misguided attempts:
\startluacode
function warnWithLabelIfVerbose( str, ... )
texio.write_nl( str .. string.format(...))
end
\stopluacode
\startMPdefinitions{doublefun}
%def somefunction ( expr str, number) =
% lua.warnWithLabel( "LABEL: ", "%s %d", str, number);
%enddef;
\stopMPdefinitions
\startMPpage[instance=doublefun]
lua.texio.write_nl( "HELLO!"); % This works
%lua.texio.write( "HELLO!\%n"); % This doesn't
%string outs; outs := lua.string.format( "HELLO! \%s \%0.3f", "aap", 12.6);
%somefunction( "aap", 12.6);
\stopMPpage