Forum: Poser - OFFICIAL


Subject: Nodes for Dummies

RobynsVeil opened this issue on Jan 24, 2009 · 490 posts


bagginsbill posted Thu, 28 May 2009 at 10:28 PM

Quote - Getting back to that init function, there's really quite a bit to it, isn't there?
You're passing 4 parameters:
item, color, shine, bump

One of those parameters (the first one) is going to define an object, and the other three parameters are actually going to be members of this object:
        item.color = color
        item.shine = shine
        item.bump = bump

With these three statements, you actually assign those parameters to the object as members of that object?

Correct. All member functions of a class are instructions on how to do something with instances of that class. The init function is the special member function describing what to do with a brand new one, and what arguments are necessary in order to create one.

The constructor is invoked by a syntax that appears to call the class name as if it were a function.

CSB(1, 2, 3)

Is actually creating a new instance of the CSB class. This is handled by the internal plumbing of the Python engine. Let's call that newcsb. Then the internal plumbing of the Python engine calls newcsb.init(1, 2, 3).

In the implementation of init, I copy the 3 arguments into attributes of the object, thus they become members of the object. Until I did that, the instance did not actually have any attributes by those 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)