Game Development Community

Help me please!! something simple driving me crazy

by Aidan Sliney · in General Discussion · 01/09/2007 (10:20 am) · 3 replies

Hi everyone!
I'm trying to get a very simple thing working!! Basically i have created the "game" from the tutorial that comes with torque - the one that has you collecting torque logos and adding up your score. I'm trying to get a "Weldone!" message to appear each time you pick up a logo. I searched through the forums and thought that by placing the following line of code inside the logoitem.cs file inside the server folder of my game under TorqueLogoItem::onCollision(%.......;

commandToClient(%obj.client,'bottomprint',"Weldone!!", 2, 1);

but this hasn't worked!! anybody know what I'm doing wrong or of another way of printing a message to the screen following a collision with an object?

Any help or tips would be really appreciated!! :-D

#1
01/09/2007 (12:58 pm)
Try this

function TorqueLogoItem::onCollision(%this,%obj,%col)
{
     %client = %col.client;
      if(%client)
     {
           commandToClient(%client,'bottomprint',"Weldone!!", 2, 1);
     }
}
#2
01/12/2007 (8:20 am)
Thanks Billy,
I put that into my logoitem.cs file that's inside the server folder but its still not working! do i have to have any corresponding code anywhere else? this is what my logoitem.cs file looks like at the moment


datablock StaticShapeData(TorqueLogoItem)
{
category = "Items";
shapeFile = "~/data/shapes/3dtorquelogo/torque_logo.dts";
};

function TorqueLogoItem::onCollision(%this, %obj, %col)
{
%client = %col.client;
if(%client)
{
commandToClient(%client,'bottomprint',"Weldone!!", 2, 1);
}
if(%col.getClassName() $= "Player")
{
%client = %col.client;
%client.score++;

commandToClient(%client, 'SetScoreCounter', %client.score);
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount > 0)
return;
// otherwise display victory screen
commandToClient(%client, 'ShowVictory', %client.score);
}
}
#3
01/12/2007 (12:11 pm)
It works for me , bottomprint shows , except for the logo stuff.

put some echos like this and test
function TorqueLogoItem::onCollision(%this, %obj, %col)
{
    %client = %col.client;
    if(%client)
    {
       commandToClient(%client,'bottomprint',"Weldone!!", 2, 1);
       echo("send bottomprint weldone to client " SPC %client);
    }

    if(%col.getClassName() $= "Player")
    {
       %client = %col.client;
       %client.score++;
       echo("increase score client " SPC %client SPC %client.score);
       
       commandToClient(%client, 'SetScoreCounter', %client.score);
       %obj.delete();
       
      %logoCount = logos.getCount();
       if(%logoCount > 0)
          return;
        
       // otherwise display victory screen
        commandToClient(%client, 'ShowVictory', %client.score);
        echo("Show victory screen" SPC %client SPC %client.score);
     }
}