Game Development Community

How to pass a variable to function that requires string input?

by Eric Preston · in Torque Game Builder · 09/04/2005 (7:15 am) · 2 replies

This is driving me nuts. I'm sure there must be a simple way to do this.

I'm trying to move the camera to center on the action in my window. So, I compute the center of mass (%com) of my sprites and try to pass this to dynamically change the target camera position. Ideally, the call might look like this:

sceneWindow2D.setTargetCameraPosition(%com 200 150 );

But, sceneWindow2D.setTargetCameraPosition() requires a string input like this: "0 0 200 150" (x/y/width/height). So, how can I get the %com variable to pass to the sceneWindow2D.setTargetCameraPosition()? I've tried getWord(%x,0) to pass x and y separately. That doesn't work.

Anybody know how to do this?

Many thanks, in advance.

Eric

#1
09/04/2005 (7:23 am)
You can build strings using SPC and @. The @ is a concatentation operator where as SPC concatanates and inserts a space between the two.

for example if
%com = "72 40";
echo( %com SPC "50 60" );
echo( %com @ "50 60" );

would return "72 40 50 60" and the second echo using @ would return "72 4050 60"
#2
09/04/2005 (9:19 am)
Gary,

I like your last name.

Many thanks, that's just what I needed.

Eric