Title: neighbor ID - why does EAxis code always do 'instance id' check? Post by: tunaisafish on 2008 October 10, 04:07:56 You can see these checks in the wants 'CT- Test' BHAV's.
These BHAV's are passed a nID which gets assigned to the Stack Ob., then the check... [prim 0x0002] Expression (Neighbor in stack object 0x0000 (person instance id) > Literal 0x0000) If this is true, I'm assuming this means that it contains a valid Object ID of the sim on the current lot. This Object ID is assigned to the stack object, and the Stack Obects person data is read/written to. If it is false, then they use Neighbor's person data instead. I can understand the reason for this in BHAV's such as 'CT - Generic Test - Max Enthusiasm?', as using the Object ID allows you to use a local variable to index into the person data array. ie. it is a speed optimization. But if you only want to access a single value in the array, is there a reason why just using the nID is wrong if the instance id is true? The only other reason I can think of is that the Object ID of the sim is a copy of the nID. ie. it will contain the most up to date info, and will be written back when the sim leaves the lot or user saves the game. Title: Re: neighbor ID - why does EAxis code always do 'instance id' check? Post by: J. M. Pescado on 2008 October 10, 04:21:21 The only other reason I can think of is that the Object ID of the sim is a copy of the nID. ie. it will contain the most up to date info, and will be written back when the sim leaves the lot or user saves the game. This is exactly it: If you use "Neighbor's Persondata", it will not return the most up-to-date information. This is particularly pertinent with information that may be subject to change while a sim is on the lot. It is somewhat less necessary, but still good practice, if the information is extremely unlikely to change: A sim's gender is probably a safe attribute to just read from neighbor's persondata without checking for instantiation, because there is nothing in the game that can really change this. Things like skills, enthusiasms, and soforth, however, *ARE* easily subject to change during gameplay and as such you should check to make sure the sim is not already present and possibly altering those attributes. |