How do I alter several variables of the same name at once?
by Maxim Eremeev · in Torque Game Builder · 11/02/2011 (1:58 pm) · 2 replies
Let's suppose, that I have several objects of the same class (let's call it "Test"), every one of which has a variable set up, that's called "Var". Is there a way for me to alter all of those variables at once in one line? For example, how do I do something like this:
to every variable, called var, that belongs to an object of the Test class? Is it even possible?
Var -= 1;
to every variable, called var, that belongs to an object of the Test class? Is it even possible?
About the author
Associate William Lee Sims
Machine Code Games
$TestSet = new SimSet(); function Test::onAdd( %this ) { $TestSet.add( %this ); } function modifyTestVars( %amount ) { %cTest = $TestSet.getCount(); for( %i = 0; %i < %cTest; %i++ ) { %obj = $TestSet.getObject( %i ); %obj.Var += %amount; } } modifyTestVars( -1 ); // From your example...