kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 19 Jan 2014 06:31 PM |
| I dont want to do for statements for how many models I have inside this model. I need something that goes though all the models, no matter how many I have? |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
| |
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 19 Jan 2014 06:34 PM |
... I wish I would have known this 2 hours ago...
Are you sure it gets ALL of them? |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
| |
|
|
| 19 Jan 2014 06:35 PM |
function FindChildren(Where) local S = {} for _,n in pairs(Where:GetChildren()) do S[#S+1] = n --wait() --Might be needed in a very very big model. FindChildren(n) end end
local Children = FindChildren(Workspace.Model) |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 19 Jan 2014 06:36 PM |
There is no GetAllChildren().
function all(obj) for i,v in pairs(obj:GetChildren()) do v.Name = "HI" all(v) end end
all(Workspace) |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
| |
|
|
| 19 Jan 2014 06:38 PM |
Oops
function FindChildren(Where) local S = {} for _,n in pairs(Where:GetChildren()) do S[#S+1] = n --wait() --Might be needed in a very very big model. FindChildren(n) end return S end
|
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
| |
|
|
| 19 Jan 2014 06:39 PM |
It returns a value to where the function was called from.
So:
function MultipliedByTwo(Number) return Number*2 end
print(MultipliedByTwo(4)) --Would print 8 |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 19 Jan 2014 06:41 PM |
| I still dont get it. Simple, no words just numbers and letters. |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 06:43 PM |
Return returns the value you are returning.
|
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 19 Jan 2014 06:45 PM |
| Because that makes just PERFECT sense...... |
|
|
| Report Abuse |
|
|
| |
|
|
| 19 Jan 2014 08:06 PM |
If you assign a value to a function that has a 'return in it', the variable will take the 'returned value'. It can also be used immediately in another function or operations though. For example:
Instance.new("blah") RETURNS an object.
math.random() returns a random number.
Now for 2 more vivid examples: (Ignore my ; at the end, habit)
function exFunc() return 3; --this is the value I'm returning, ALWAYS 3 end
myNumber = exFunc(); print(myNumber); --> 3
But I can simply use the function directly:
print(exFunc()); --> 3
And a calculator:
function add(Num1, Num2) return Num1 + Num2; end
myNumber = add(5, 7); print(myNumber); --> 12
myNumber = add(myNumber, add(3, 5)); --> here we take the value returned from the innermost function (add(3, 5) which is 8) and it replaces the second argument, Num2, so it adds 12 and 8 print(myNumber); --> 20 |
|
|
| Report Abuse |
|
|