Game Development Community

Append numbers to a string

by Kyle Cook · in Torque Game Engine · 06/13/2006 (10:04 am) · 4 replies

I am trying to slap a number at the end of a string but for some reason the number isn't sticking. If this were java I could do one of those fancy .toString() calls and then append it to the string, but I don't know how it is done in TorqueScript.

Here is the code I am looking at. The problem code is in bold.

function serverCmdFetchCharacterList(%client,%AccountName)
{
   %query = "Select Name FROM Characters Where AccountName= \'"@%AccountName@"\'";
   %result=$SqLite.query(%query,0);
   %this.counter=0;
   while (!$SqLite.endOfResult(%result))
   {
      %name = $SqLite.getColumn(%result, "Name");
      echo("get name " @ %name);
      [b]%slot="c"@%this.counter@"";[/b][i] // The server just recieves the 'c' and not a number at the end.[/i]
      CommandToClient(%client,'FetchedCharacter',%name,%slot);
      %this.counter++;
      $SqLite.nextRow(%result);
   }
}

If ya got a solution, toss it my way please.

#1
06/13/2006 (10:23 am)
I dont think %this.counter is a valid variable since %this is not defined anywhere. Try just using %counter;
#2
06/13/2006 (10:30 am)
That worked, thanks! Now I have to figure out why my server is crashing.. Something in the way I am loading the mission I assume..
#3
06/13/2006 (10:33 am)
Try stepping trough your debugger if you have one.
#4
06/13/2006 (10:35 am)
This debugger you mention sounds useful, any suggestions?