I am toying with luadraw and would like to have my graphic depending on \thepage for the number of iterations. I tried \\thepage, "\\thepage" or to use g:Writeln or tex.sprint but none of them worked.
Minimal non-working example (inspired by the luadraw manual):
%!TEX TS-program = lualatex
\documentclass{article}
\usepackage{luadraw}
\begin{document}
bla blo bli
\begin{luadraw}{name=Sierpinski}
local iteration = g:Writeln("\\thepage") %num? tex.sprint?
local g = graph:new{window={-5,5,-5,5},margin={0,0,0,0},size={1,1}}
local i = cpx.I
local rand = math.random
local A, B, C = 5*i, -5-5*i, 5-5*i -- triangle initial
local T, niv = {{A,B,C}}, iteration
for k = 1, niv do
T = concat( hom(T,0.5,A), hom(T,0.5,B), hom(T,0.5,C) )
end
for _,cp in ipairs(T) do
g:Filloptions("full", rgb(rand(),rand(),rand()))
g:Dpolyline(cp,true, "line width=0pt")
end
g:Show()
\end{luadraw}
\end{document}

ggraphic object (g:Writeln()) before you've created that object. Furthermore, theg:Writeln()method writes a string to the tikzpicture environment, but doesn't return a value (so it returnsnil).