I want to do a search through my game.Workspace for all Instances whose name starts with “Proxy_”.
Historically I’ve done this with a utility function I have that maps a function over a sub-tree of the datamodel with a depth-first recursive search.
Is it better to use game.Workspace:GetDescendants ()?
Pros:
probably faster
maybe a little cleaner
maybe a little easier to understand
Cons:
will this thing really return an array with 100k instances in it? Or is there some secret undocumented limit?
maybe uses more memory?
A function to map a lambda over a sub-tree of the datamodel would be a really useful built-in function.
2 Likes
Have you tried looking into CollectionService ? Basically you can tag each object that has that name and loop through all of them without worrying if it is that or not.
6 Likes
Quenty
(Quenty)
June 2, 2020, 8:49pm
#3
There are no limits, but you want to use CollectionService with this tag editor!
This is a plugin for editing CollectionService tags. If you aren’t familiar with what that is, please read the wiki page and then continue reading this post: http://wiki.roblox.com/index.php?title=API:Class/CollectionService
This plugin allows you to create tags, and then assign them to objects in your game. You can also visualize and view a list of what objects have a given tag, and so on. It’s become an essential tool in many game developers’ toolboxes.
Why use CollectionService?
Collec…
You can also listen to items being added and removed, which is what I do with my binding system.
--- Bind class to Roblox Instance
-- @classmod Binder
local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Nevermore"))
local RunService = game:GetService("RunService")
local CollectionService = game:GetService("CollectionService")
local Maid = require("Maid")
local Signal = require("Signal")
local promiseBoundClass = require("promiseBoundClass")
--[[
@usage
-- Setup a class!
local MyClass = {}
MyClass.__index = MyClass
function MyClass.new(robloxInstance)
print("New tagged instance of ", robloxInstance")
This file has been truncated. show original
4 Likes
I’ve never heard of this service before.
The part where the tags don’t appear in Studio is kind of a bummer. I would want to create tags on my proxy objects as part of the authoring step.
Seems like a much better way to index into the datamodel though.
4 Likes