ldo/ShaderTools — comment on commit 53c5963d10c0d99e0c42e3f9a9d8e70d9839d4eb
File:  line 0
By ldo:

The next key point about the rework is the dictionaries of field definitions. For example, the large “material_fields” table is full of entries like these:

"Mat_diffuse_intensity" : {"attr" : ("diffuse_intensity",)},
"Mat_diffuse_color_r" : {"attr" : ("diffuse_color", 0)},
"Mat_transparency_fresnel" : {"attr" : ("raytrace_transparency.fresnel",)},

and some of the entries also have a “convert” component added. The dictionary key is the database field name, while the value is another dictionary, with an “attr” field that describes the corresponding Blender object attribute. This field value is always a tuple: it can have a single element, which is the attribute name, or it can have a second element which is an index into an array-valued attribute. If the attribute name string has dots in it, then that means you have an attribute returning a subobject, in which you access another attribute. All the logic for interpreting this is in the “SetupObject” routine, which is used to set up both materials and textures. Notice how much smaller it is than the original screeds and screeds of code which were individually assigning field values to object attributes!