|
It's a small funtion idea I came up of. Possible uses, may be useful.
Name: ":getFamily(n)"
Type: Function
Description: This will return with a table with the family (Parent AND Children) of an object. The n represents how far it will return, so if I put 2, it will return with Parent's Parent, and Children's Children (also including the parent and the children).
Example1
|Workspace
|--Model
|----Part
|------Value
|--------Script
|------Script2
Inside Script2...
family = script.Parent:getFamily(2)
Returns with a table {Model, Workspace, Value, Script, Script2}.
Example 2
|Players
|--RevolutionGG
|----Backpack
|----StarterGear
|----PlayerGui
|------SceenGui
|--------Frame
|--------Script
|----------TextButton
Inside the script...
t = script.Parent.Parent:getFamily(1)
Returns with a table {StarterGear, Backpack, RevolutionGG, ScreenGui}
Don't understand? Then ask me for further info... |
|
|
|
So it returns the object the method was called on, and its children, and its childrens children?
Why not
GetDecendants() to return a table with the objects children, and there childrens children, and there childrens children, ect then insert the object into the table |
|
|
Also, why bother with setting it to 1? Its the same as :children() and table.insert(tab,obj) |
|
|
It's also returning the relations within the Parent's object, so if you had torso and used :getFamily(1), you'd get Head, Legs, Arms, Scripts, Humanoid, Etc... |
|
|
so
+Model
++Torso:getFamily(1)
++Arms
++Legs
++Head
++Scripts
Torso
Arms
Legs
Head
Scripts?
Torso.Parent:children() |
|
|
Not only that, and also it return with their childrens, if they have one.
|Workspace
|--Model
|----Brick
|------Value
|--------Script
|----------StringValue
If you use :getFamily(2) in the script, it will return with {Value, Brick, StringValue}. |
|
|
So why not just make a GetDecendants() that returns a table with the instance's children, and there children, and there children.
Like a not-so-laggy recusive script. |
|
|
Because it returns the Parent, too. |
|
PiezRusJoin Date: 2010-06-06 Post Count: 1354 |
great idea revolution, bump and support |
|
|
|
Cant you use GetDescendants on it's parent?
EG:
function Lolcats(number)
for i = 1, number do
lolstring=lolstring..".Parent"
end
lolstring="script"..lolstring
a=loadstring(lolstring)()
return a:GetDescendants()
end |
|
|
Workspace:getDescendant()? Then keep doing :IsA() over and over again? |
|
|
I'm not sure on loadstring but look what I posted. |
|
|
|
'Because it returns the Parent, too.'
modelnchildren = workspace.Model:decendants() --Contains the Children of Model, but not the Model
table.insert(modelnchildren,workspace.Model) --Now contains the Children of Model, and Model |
|
|
numerlogiJoin Date: 2010-04-17 Post Count: 1082 |
dude aready scriptable |
|
|
@numer: Yes, but its laggy. a C(#/++) GetDecendants/Family (Decendants better) SHOULD lag less than Lua Get Family/Decendants |
|
|
|
|
This is somewhat already scriptable. |
|
|