I have a little question about scripting ^^ :
is it possible to save the object address (OBJ_XX) in a variable for example a string and select the needed object with switch?
(i tried string and it doesn't work)
Vector3 pos1, pos2, pos0, UpLoc;
int x;
Quaternion orientation1;
string tower, target;
void Main()
{
switch(x)
{
case 0:
x=1;
tower = "OBJ_88";
target = "OBJ_22";
break;
case 1:
x=0;
tower = "OBJ_132";
target = "OBJ_154";
break;
};
iObjectLocation(tower, pos1); //obj_88 = tower
iObjectLocation(target ,pos2); //obj_22 = target
pos0.x = pos1.x-pos2.x;
pos0.y = pos1.y-pos2.y;
pos0.z = pos1.z-pos2.z;
pos1.y += 4;
pos1.z -= 2;
x = iVectorLengthSq(pos0);
if (x < 10000)
{
UpLoc = Vector3(1,1,1);
iQuaternionLookAt(orientation1,pos2-pos1, UpLoc);
iObjectOrientationSet(OBJ_0,orientation1);
iObjectLocationSet(OBJ_44,pos2);
iObjectStart(OBJ_44);
}
}
is it possible to save the object address (OBJ_XX) in a variable for example a string and select the needed object with switch?
(i tried string and it doesn't work)
Vector3 pos1, pos2, pos0, UpLoc;
int x;
Quaternion orientation1;
string tower, target;
void Main()
{
switch(x)
{
case 0:
x=1;
tower = "OBJ_88";
target = "OBJ_22";
break;
case 1:
x=0;
tower = "OBJ_132";
target = "OBJ_154";
break;
};
iObjectLocation(tower, pos1); //obj_88 = tower
iObjectLocation(target ,pos2); //obj_22 = target
pos0.x = pos1.x-pos2.x;
pos0.y = pos1.y-pos2.y;
pos0.z = pos1.z-pos2.z;
pos1.y += 4;
pos1.z -= 2;
x = iVectorLengthSq(pos0);
if (x < 10000)
{
UpLoc = Vector3(1,1,1);
iQuaternionLookAt(orientation1,pos2-pos1, UpLoc);
iObjectOrientationSet(OBJ_0,orientation1);
iObjectLocationSet(OBJ_44,pos2);
iObjectStart(OBJ_44);
}
}