Roody_Yogurt wrote:
Checking if a component has an attribute:
Code: Select all
if self.part_of and self.part_of is <attribute>
That might be enough, for my purpose. I was not aware that a construct like "self.part_of is scenery" is legal code. I find that very interesting.
Still, I
might want to explicitly write a condition dependent on the identity of the "part_of" object. Using the logic of "self.part_of is scenery", perhaps something like this, checking to see whether the knob is part of the cabinet:
And just to be sure that I understand, I know that the knob is part of the cabinet and I want to find out whether the cabinet is hidden:
Roody_Yogurt wrote:
So you'd want (not that you'd do this):
Code: Select all
if self.part_of
run self.part_of.long_desc
I would rather just put a condition in the new class's long_desc (and possibly short_desc, etc.) that prints different text depending on what object the component is part of, or whether the object that the component is part of has a given attribute.
Roody_Yogurt wrote:
Another thing to be aware of is there is an extra layer of complexity if your game has components-of-components. loafingcoyote's and my CheckReach fix has the following code to keep such things in scope:
That's interesting. I probably won't need to use the fix, though. I don't think I'm going to need components of components.
Thank you, Roody. That helps a lot.