Hi xus,
xusword
is it possible to do
foo(){
i=10;
run(“setenv VAR…?”); // assign VAR to i
}
Concatenate the command and the variable (using the ‘+’ operator) to form the final command string, like this:
foo()
{
float i=10;
run(“setenv VAR = ” + i + “; varchange”);
}
The second command “varchange” is there to force a recook of all operators which reference $VAR – otherwise the value of $VAR would change, but things wouldn't necessarily update.
And similarly:
vector foo() {
if ($activate>0) {
// calculate x, y, z
run(“setenv DefPosX = ” + x);
run(“setenv DefPosY = ” + y);
run(“setenv DefPosZ = ” + z);
run(“varchange”);
}
return vector3(x,y,z);
}
Note that even though the function's return type is
vector, the actual return value is constructed with
vector3(). Also note that the global is stored as three separate components, otherwise it would end up with the string-formatted version of the vector: something like "“ instead of the actual numerical values. Wherever you need to use the global ”DefPos" in vector form, you'd use the expression
vector3($DefPosX,$DefPosY,$DefPosZ).
P.S: Are you “KeKe” over at the od forum? (just curious)
Cheers!