I would like to create a command that simply prints what I give to it, but through Lua. Pointless for now, but I want to expand this to a more complex use-case. I've read a few answers around here, but can't quite figure it out. Simply put, if I give my command hello \bfseries world as an input, I'd like the output to show "hello world".
\documentclass{article}
\usepackage{luacode}
\newcommand\mycmd[1]{%
\directlua{tex.sprint("--->".."\luatexluaescapestring{#1}") }
}
\begin{document}
\mycmd{Hello world}
\mycmd{Hello \world} % a bit surprised \ works, why?
\mycmd{Hello \bfseries world} %
\end{document}

"\luaescapestring{\unexpanded{#1}}"– Henri Menke Apr 02 '21 at 18:37\luastringNis available when you work withluacode– Apr 02 '21 at 18:38