Game Development Community

Concatenation problem

by Drew Madsen · in Torque Game Engine · 08/14/2009 (7:35 am) · 2 replies

Making a for loop to call a variable using concat, getting a syntax error and can't see it.


%meleeP1 = gettranpos(%this.getslottransform(29));

%foeP0 = gettranpos(%foe.getslottransform(19));
%foeP1 = gettranpos(%foe.getslottransform(20));
%foeP2 = gettranpos(%foe.getslottransform(21));
%foeP3 = gettranpos(%foe.getslottransform(22));
%foeP4 = gettranpos(%foe.getslottransform(23));
%foeP5 = gettranpos(%foe.getslottransform(24));
%foeP6 = gettranpos(%foe.getslottransform(25));
%foeP7 = gettranpos(%foe.getslottransform(26));
%hit = 0;
for (%i = 0; %i<8; %i++)
{
%foepoint = "%foeP"@%p@;//<-The Line that gets an error
if (vectordist(meleeP1,%foepoint)<1)
%hit = 1;
}

The syntax error comes up when I set %foepoint

#1
08/14/2009 (8:13 am)
There are a couple of problems with your code. First the line that gets the error ends with an "@". There has to be something on both sides of the concat operator. Second, you're using a variable %p when you apparently want to use %i. Even if you delete that "@" and change %p to %i, the code still wouldn't work, because your variable %foepoint would equal the string "%foeP0", for example, and not the actual transform. Try replacing that line with:

eval("%foepoint = %foeP" @ %i @ ";");

This command will form the string "%foepoint = %foeP0;" for example, and execute it.
#2
08/14/2009 (2:24 pm)
Ahh thankyou!

I'm using p in my script on my lap top, I switched to the for with the %i just to give the example.

Pretty sure this info will get things working for me.