Variable as function call
by Howard Dortch · in Torque Game Engine · 12/06/2005 (6:22 am) · 5 replies
I would like to construct a call to a function using a variable. Have tried different methods with no success. Anyone know how to do this?
example:
%func = $GameName@"EquipPlayer";
%func(%player);
example:
%func = $GameName@"EquipPlayer";
%func(%player);
#2
eval(%func,%var) doesn't seem to work
12/06/2005 (7:17 am)
Thanks Tim! how would I go about passing a parameter?eval(%func,%var) doesn't seem to work
#3
Where %func contains the name of the function you wish to call and %p1 .. %p6 are
variables holding each value you wish to pass.
12/06/2005 (7:28 am)
You could pass parameters using:eval(%func@"(%p1,%p2,%p3,%p4,%p5,%p6);");
Where %func contains the name of the function you wish to call and %p1 .. %p6 are
variables holding each value you wish to pass.
#4
%func = "mSin(3.14);"
%result = eval(%func);
Edit: Gary said it better.
12/06/2005 (7:30 am)
When you build %function, make sure you use quotes around the string, as in%func = "mSin(3.14);"
%result = eval(%func);
Edit: Gary said it better.
#5
12/06/2005 (8:11 am)
Thanks Tim and Gary that works!!
Torque Owner Tim Hutcheson
eval(%func);