SimSets and delete()
by Vern Jensen · in Torque Game Builder · 07/03/2007 (2:08 pm) · 3 replies
In experimenting with SimSets, I've discovered that apparently, if you delete an object, it is also automatically removed from any SimSets that it was stored in. Is this true? For instance:
Let's say initiall the SimSet mySimSet contains 3 objects. It will echo:
Initial count of SimSet: 3
Latter count of SimSet: 2
So apparently, even though I *never* issued a %mySimSet.remove(%object) command, it seems that Torque is smart enough to remove the object from the SimSet automatically. Even though this has been my experience thanks to experimentation, I just want to confirm on here that this is indeed the behavior. I assume this happens on *all* SimSets, so if a given object is part of many SimSets, when it is deleted, it will be removed from all of them?
Such automatic behavior is indeed nice, provided one knows about it and expects it. ;-)
echo("Initial count of SimSet: " @ %mySimSet.getCount());
%object = %mySimSet.getObject(1);
%object.delete();
echo("Latter count of SimSet: " @ %mySimSet.getCount());Let's say initiall the SimSet mySimSet contains 3 objects. It will echo:
Initial count of SimSet: 3
Latter count of SimSet: 2
So apparently, even though I *never* issued a %mySimSet.remove(%object) command, it seems that Torque is smart enough to remove the object from the SimSet automatically. Even though this has been my experience thanks to experimentation, I just want to confirm on here that this is indeed the behavior. I assume this happens on *all* SimSets, so if a given object is part of many SimSets, when it is deleted, it will be removed from all of them?
Such automatic behavior is indeed nice, provided one knows about it and expects it. ;-)
#2
For reference, it's called "smart referencing", and it's implemented that way because the engine wants to make sure that there are no references or associations existing to an object that itself no longer exists.
07/03/2007 (2:21 pm)
Yes, it does, and it is one of the fundamental things the engine provides for you--one of the good reasons to use an engine :)For reference, it's called "smart referencing", and it's implemented that way because the engine wants to make sure that there are no references or associations existing to an object that itself no longer exists.
#3
07/03/2007 (3:43 pm)
Very cool. Thanks!
Associate Orion Elenzil
Real Life Plus
yes.