This post is origined from this excellent answer of luadraw:
Now assuming that I was neglected the [1] after parametric3d(function(t) return M(t,0,3/(t^2+0.5)) end,0,7,15):
\documentclass[border=5pt]{standalone}
\usepackage[svgnames]{xcolor}
\usepackage[3d]{luadraw}%v2.2
\begin{document}
\begin{luadraw}{name=surface}
local g = graph3d:new{window3d={-5,5,-5,5,-1,6},adjust2d=true,bbox=false,size={10,10}, viewdir={-30,50}}
g:Labelsize("footnotesize")
local curve = parametric3d(function(t) return M(t,0,3/(t^2+0.5)) end,0,7,15)-- [1]
-- I forget `[1]` here.
-- The points on this curve are not regularly spaced.
local S = rotline(curve,{Origin,vecK},-180,180)
-- We rotate the curve around the axis (O,k) to obtain the surface.
g:Dboxaxes3d({grid=true,gridcolor="gray",fillcolor="LightGray",xyzstep=2})
g:Dfacet(S, {usepalette={palAutumn,"z"},clip=true})
g:Dpolyline3d(curve,false,"DarkGreen,line width=0.8pt",true)
g:Ddots3d(curve,"scale=0.75,DarkGreen",true)
g:Dlabel3d("curve $M(t,0,\\frac3{t^2+0.5})$",M(5.5,0,0),{dir={vecJ,vecK},node_options="DarkGreen"})
g:Show()
\end{luadraw}
\end{document}
Then run with lualatex, I would get:
...2025/texmf-dist/tex/lualatex/luadraw/luadraw_build3d.lua:383: attempt to index a nil va
lue (local 'S')
stack traceback:
...2025/texmf-dist/tex/lualatex/luadraw/luadraw_build3d.lua:383: in function 'clip3d'
...2025/texmf-dist/tex/lualatex/luadraw/luadraw_graph3d.lua:1344: in function 'luadraw_graph3d.Dfacet'
[\directlua]:7: in main chunk.
\luacode@dbg@exec ...code@maybe@printdbg {#1} #1 }
l.18 \end{luadraw}
Now, I have two options to debug:
- to read the error information
attempt to index a nil value (local 'S')which is not really readable friendly - dive into the manual, to consult what
parametric3dreturns
As nidarfp mentioned at here:
parametric3d()returns a list (table) of lists of 3d points, because a curve can be made up of several pieces (several connected components), so[1]means that we take the first component of the curve (and as the function is continuous, there is no other)
Or conduct some debug to show some intermediate variables, such as in my case, I want to know what is local S actually look like.
In tikz case, we can use \node {<somevalue I want to know>}; to show what it is. But in the world of luadraw, I know little.
Is that any easy method in this specific case to know what local S, which is actually "a list (table) of lists of 3d points"? with which, it could be more easier for me to debug and know I only need to use the first component of the curve.
Edited:
As nidarfp show isListOfPt3d and isListOfListOfPt3d to detect what local S actually is. But what I was after is a more general "debug" scheme. Take tikz as an example:
\documentclass[tikz,border=5pt]{standalone}
\begin{document}
\def\radius{1}
\def\height{1.05}%to tune the eccentricity
\def\leftheight{2}
\def\rightheight{4}
\def\midheight{\fpeval{(\leftheight+\rightheight)/2}}
\def\hh{\fpeval{abs(\leftheight-\rightheight)/2}}
\begin{tikzpicture}[line join=round]
\draw[dashed] (\radius,0) arc (0:180:{\radius} and {1/3});
\draw (-\radius,0) arc (180:360:{\radius} and {1/3});
\draw (-\radius,0) -- (-\radius,\leftheight) coordinate (A);
\draw (\radius,0) -- (\radius,\rightheight) coordinate (B);
\def\phii{\fpeval{acos(\hh/\height)}}
\def\xa{0}
\def\ya{\fpeval{-\height*sin(\phii)}}
\def\xb{\radius}
\def\yb{\fpeval{\height*cos(\phii)}}
\draw[cm={\xa,\ya,\xb,\yb,(0,\midheight)}] circle [radius=1cm];
\filldraw[red] (A) circle[radius=.5pt] node[left,text=black] {$A$} (B) circle[radius=.5pt] node[right,text=black] {$B$};
\node[align=left,rectangle] at (\radius+4,\rightheight/2) {%
$\phi$ \texttt{=\phii}\\
$(x_1,y_1)$ \texttt{=(\xa,\ya)}\\
$(x_2,y_2)$ \texttt{=(\xb,\yb)}
};
\end{tikzpicture}
\end{document}
In the above coding process, I could use:
\node[align=left,rectangle] at (\radius+4,\rightheight/2) {%
$\phi$ \texttt{=\phii}\\
$(x_1,y_1)$ \texttt{=(\xa,\ya)}\\
$(x_2,y_2)$ \texttt{=(\xb,\yb)}
};
to show the parameters' value, which helps me to check whether my code is correct.
but is that possible I could show that local S=surface(...), which is something like:
S = { {Z(-4,0), Z(0,2), Z(1,3)}, {Z(0,0), Z(4,-2), Z(1,-1)}}
in the PDF, or in the teriminal or .log file, to help debug for the datas structure(?) with luadraw? Define a function to test elements' type and content is not generally a efficient debug method...
Or I can take another example with Python, if we saw that print(element) gives:
element = [ [1,2,3] , [2,3,4,5] ]
It's easily to know that is "list in list", and we can use element[0] or element[1][2] to index what we want. Is that possible for lualatex to provide something like this to help debug and programming?
I hope with the parallel examples, I make it clearly....


print(S)(in luadraw code) to see S in the terminal, but lua will printtable, to see the elements you must useprint(table.unpack(S)).lua!