After my previous question, I want to plot a 3d surface; as a simple function I tried to render the bellow plot but I was not successful.
\documentclass{standalone}
\usepackage{blindtext}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{tikzpicture}
\directlua{
q = function(x)
return x-1
end
z = function(x,y)
return x^2+y^2+q(x)
end
}
\pgfmathdeclarefunction{z}{2}{%
\edef\pgfmathresult{\directlua{tex.print(z(\pgfmathfloatvalueof{#1},\pgfmathfloatvalueof{#2}))}}%
}%
\begin{axis}
[
axis lines=center,
enlargelimits,
tick align=inside,
domain=-1:1,
samples=200,
minor tick num=5,
]
\addplot3 [surf] {z(x,y)};
\end{axis}
\end{tikzpicture}
\end{document}

