Took me longer than I’d like to admit to realize that \directlua is first expanded before it goes into the lua interpreter, and that \% is defined through \chardef (in plain), which means that it’s not expandable.
Luckily LuaTeX has the \csstring primitive.
Is anyone else doing any fun things with \directlua?