Applying functions to a bunch of objects . . .
by Kevin James · in Torque Game Builder · 02/15/2008 (2:44 pm) · 3 replies
How is it going?
I was just wondering if there was an easy way to tell a whole group of objects to do a certain function -- taking for granted that I am passing in the same arguments.
Say I have 20 objects all named: "lenin1, lenin2, lenin3 . . . lenin20". Is there any easy way to change their blend color as a group -- without doing something like:
Get what I'm saying? Thanks, I'd appreciate any insight on the issue.
--Kevin
I was just wondering if there was an easy way to tell a whole group of objects to do a certain function -- taking for granted that I am passing in the same arguments.
Say I have 20 objects all named: "lenin1, lenin2, lenin3 . . . lenin20". Is there any easy way to change their blend color as a group -- without doing something like:
lenin1.setBlendColor(0, 0, 0, 1); lenin2.setBlendColor(0, 0, 0, 1); lenin3.setBlendColor(0, 0, 0, 1); . . . lenin20.setBlendColor(0, 0, 0, 1);
Get what I'm saying? Thanks, I'd appreciate any insight on the issue.
--Kevin
About the author
Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/
#2
Thanks a lot man, this is exactly what I was looking for! I've often wondered how to call a function like a string, this "eval" function should come in handy. I had a suspicion that a simSet had something to do with it; that seems like a more viable solution, especially if the objects don't all have the same name.
Currently I don't really have a problem, but I've often wondered how to do something like this. This will save me a lot of time in the future with my scene object based GUI's.
Thanks again,
Kevin
02/15/2008 (8:28 pm)
Phillip,Thanks a lot man, this is exactly what I was looking for! I've often wondered how to call a function like a string, this "eval" function should come in handy. I had a suspicion that a simSet had something to do with it; that seems like a more viable solution, especially if the objects don't all have the same name.
Currently I don't really have a problem, but I've often wondered how to do something like this. This will save me a lot of time in the future with my scene object based GUI's.
Thanks again,
Kevin
#3
Just used something similar to your first example in the latest Unek prealpha.
Drop me an email at: syreal@syrealgames.com and I'll send you the link. I'm not wanting the project to go full-scale public, but I'd like to get another TGB developer's opinion on it. If you don't send me an email, I'll assume you're waiting so that you can be fully blown away by the full game whenever the "full" game does come out.
Peace out,
(bah) Kevin
02/17/2008 (10:58 am)
Phillip,Just used something similar to your first example in the latest Unek prealpha.
Drop me an email at: syreal@syrealgames.com and I'll send you the link. I'm not wanting the project to go full-scale public, but I'd like to get another TGB developer's opinion on it. If you don't send me an email, I'll assume you're waiting so that you can be fully blown away by the full game whenever the "full" game does come out.
Peace out,
(bah) Kevin
Associate Phillip O'Shea
Violent Tulip
for (%i = 1; %i <= 20; %i++) eval("lenin" @ %i @ ".setBlendColor(0, 0, 0, 1);");Crude, but effective.
Alternatively, if you had each of the "leninX" object in a simset you could do: