I am learning python and panda3d currently.
I have a nested list which i need to convert into a list of coordinates.
my input is
[['g,g', 'g,g'], ['d,d', 'd,d,d', 'd,d], ['s,s', 's,s']]
The Output that I need is another list:
[(0,0,0,'s'),(0,1,0,'s'),(1,0,0,'s'),(1,1,0,'s'),(0,0,1,'d'),(0,1,1,'d'),(1,0,1,'d'),(1,1,1,'d'),(1,2,1,'d'),(2,0,1,'d'),(2,1,1,'d'),(0,0,2,'g'),(0,1,2,'g'),(1,0,2,'g'),(1,1,2,'g')]
this simple list conversion is scrambling my brain. o.0
EDIT: more info:
in the input list, the last nested list represents the base layer.
The idea was to convert string i have written in a file into coordinate points. This is the content of the file:
[LVL02]
g,g
g,g
[/LVL02]
[LVL01]
d,d
d,d,d
d,d
[/LVL01]
[LVL00]
s,s
s,s
[/LVL00]
this should give me a very basic map maker. each level is a flat 2d surface.
[LVL02]
g,g (0,0,2,'g'),(0,1,2,'g')
g,g (1,0,2,'g'),(1,1,2,'g')
[/LVL02]
[LVL01]
d,d (0,0,1,'d'),(0,1,1,'d')
d,d,d (1,0,1,'d'),(1,1,1,'d'),(1,2,1,'d')
d,d (2,0,1,'d'),(2,1,1,'d')
[/LVL01]
[LVL00]
s,s (0,0,0,'s'), 0,1,0,'s')
s,s (1,0,0,'s'),(1,1,0,'s')
[/LVL00]
ie. (xaxis,yaxis,zaxis, type)
It might be this:
… but as it has been written, it is not clear what the rule is exactly. In nested loops: