ZachBloxx
|
  |
| Joined: 26 Jun 2013 |
| Total Posts: 2833 |
|
|
| 06 Oct 2013 09:37 PM |
Do you think this would be a good method for ROBLOX to add, or would it be a waste since you can easily make a custom function to return a table of all the descendants of an object?
I wouldn't mind if it were to get added, I could see me using it occasionally. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Oct 2013 09:48 PM |
Would it return, like:
{Part, Part, {Model Children}} Or? |
|
|
| Report Abuse |
|
|
ZachBloxx
|
  |
| Joined: 26 Jun 2013 |
| Total Posts: 2833 |
|
|
| 06 Oct 2013 09:51 PM |
Just a table of all the descendants of the object the method is being used on.
For example:
for i,v in next, Workspace:GetDescendants() do print(v) end
It would print any item that is a descendant of workspace. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Oct 2013 09:54 PM |
So any non-model descendents? Otherwise, GetChildren already does that...
|
|
|
| Report Abuse |
|
|
ZachBloxx
|
  |
| Joined: 26 Jun 2013 |
| Total Posts: 2833 |
|
|
| 06 Oct 2013 09:59 PM |
:GetChildren() only returns a table of the direct children the method it is being used on.
Try this:
for i,v in next, Workspace:GetChildren() do print(v) end
Now try this:
local DescendantsTable = {}; local function GetDescendants(Obj) for i,v in next, Obj:GetChildren() do table.insert(DescendantsTable, v) GetDescendants(v) end return DescendantsTable; end
for i,v in next, GetDescendants(Workspace) do print(v) end
They get different results, so GetChildren doesn't do this. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Oct 2013 10:00 PM |
But you can't do universal things, like:
You can't do GetDescendents... .BrickColor since you will get models, sounds, etc. |
|
|
| Report Abuse |
|
|
ZachBloxx
|
  |
| Joined: 26 Jun 2013 |
| Total Posts: 2833 |
|
|
| 06 Oct 2013 10:03 PM |
I don't quite understand what you mean by that.
for i,v in next, Workspace:GetDescendants() do if v:IsA('BasePart') then v.BrickColor = BrickColor.new('Bright red') end end
? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Oct 2013 10:31 PM |
Oh, so it just returns all descendants in 1 table, no matter where it is. Yeah, I guess that could work |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 07 Oct 2013 05:04 AM |
That is an goo... I mean evil idea, I like it.
Yes, we can make stuff that acts like your idea, but I'd say it makes things way easier having a method like that - Then the only question is efficiency?
- Evil As, got idea for ze AssetService. :I |
|
|
| Report Abuse |
|
|
|
| 07 Oct 2013 09:25 AM |
| It's a good idea for ROBLOX to add commonly used methods to their API officially, to both increase the speed of our scripts and increase the readability. |
|
|
| Report Abuse |
|
|