Hello fellow gangsters,
I’ve made a better version of Collector module.
This one should have more use cases unlike the original one and is thus hopefully more performant.
About
FamilyCollector is a module that uses the CollectionService for collecting all the Instances with either the Parent Tag or Tagged Tag.
The collected “Parents” will be stored in the “Instances” table inside the so called “FamilyCollector” as the index and with a table as value.
The only interesting thing about the table of the “Parent” is the “Tagged” table, this table stores all the instances with the Tagged “Tag” who are descendants of the parent.
Module
Functions
module.CreateCollector = function(parentTag : string, tag : string, validParentClasses : {string?}, validTaggedClasses : {string?}, changedFunction : (changeType : number, parent : Instance, tagged : Instance?) → nil) : FamilyCollector?
Creates and returns a FamilyCollector.
module.FillCollector = function(self : FamilyCollector)
This is the function used internally to collect all the Parents and Tagged.
You can still use this normally hence theres no way for it to fill with the same stuff twice.
Properties
FamilyCollectors : {FamilyCollector}
This just shows all the current FamilyCollectors existing.
FamilyCollector
Properties
ValidParentClasses : {string?}
The table that contains all the valid ClassNames that the Parents can have.
ValidTaggedClasses: {string?}
The table that contains all the valid ClassNames that the Tagged Instances can have.
ParentTag : string
The Tag used for searching for the Parent Instances.
Tag : string
The Tag used for searching for the Tagged Instances.
Instances : { { Tagged : { Instance }, Connections : { RBXScriptConnection } } }
ChangedFunction : (changeType : number, parent : Instance, tagged : Instance?) → nil
This is the only property that you should change, if you want to.
The “changeType” can be only a set number, those being:
[1]: Parent Added
[2]: Parent Removed
[3]: Tagged Added
[4]: Tagged Removed
The “tagged” will only be an Instance when the it’s either 3 or 4.
(I realised while writing this that theres no “self” being passed through, so I’ll have to fix that when I can)
Functions
Destroy : (self : FamilyCollector) → nil
As the name says/implies, this just straight up deletes the FamilyCollector and cleans up all the connections, nothing of note to be said here.
Important Information
Changing the Tag, ParentTag, ValidParentClasses and ValidTaggedClasses won’t update the Instances table nor any deriative tables.
Please note that the current version of this post has all been written using my memories of how the module worked, it might work differently, but you can just look into the code because it is written really simply.
Module Link:
I hope this can be of use for some people, if there are any issues (that haven’t been noted in the post), please tell me about them.