RobynsVeil opened this issue on Jan 24, 2009 · 490 posts
bagginsbill posted Wed, 25 February 2009 at 3:18 PM
Regarding the error:
outputs += makeSurface()
This is very simple. You were trying to add a surface to a list. Python doesn't want that here. It wants a list of surfaces. The correct syntax would be:
outputs += [ makeSurface() ]
And as you discovered, you don't really need this here. For a script that only produced one surface, you don't have to do anything but make the surface. If the script actually does make more than one surface, and you do nothing else, the last surface made will be what is produced.
The reason to use the outputs += business is if you want the single script to generate multiple output surfaces - i.e. multiple material files.
So, for example, if you go to your parameterized version:
def makeSurface(x): ...
Suppose you want the script to generate three surfaces in different colors. You could do:
outputs += [ makeSurface(RED), makeSurface(GREEN), makeSurface(WHITE) ]
You could instead say:
outputs += [ makeSurface(RED) ]
outputs += [ makeSurface(GREEN) ]
outputs += [ makeSurface(WHITE) ]
That would do the same thing.
Now in either case, matmatic would have to decide what to call these surfaces, since you didn't say. So it would just number them for you. It adds a suffix to the name of the script, so if the script is foo.mm1.txt, the results would be foo-1.mt5, foo-2.mt5, and foo-3.mt5.
This could get confusing, so you want to take advantage of the ability to specify the suffix yourself.
outputs += [ "Red", makeSurface(RED) ]
That would produce foo-Red.mt5.
outputs += [
"Red, makeSurface(RED),
"Green", makeSurface(GREEN),
"White", makeSurface(WHITE),
]
That would produce the three variations with nice names.
Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)