Gameone Tutorial Scoring functions not getting called
by Dan Rubenfield · in Torque Game Engine · 07/13/2006 (12:32 pm) · 3 replies
So the clientGame.cs functions don't seem to be getting called.
First, the code:
Logoitem.cs:
function TorqueLogoItem::onCollision(%this, %obj, %col)
{
if(%col.getClassName()$= "Player")
{
$client = %col.client;
%client.score++;
commandToClient(%client, "SetScoreCounter", 2);
commandToClient(%client, "TestEcho");
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount>0)
{
return;
}
else
{
commandToClient(%client, 'ShowVictory', %client.score);
}
}
}
I added in a testEcho command as well as the original value to see if that was the problem.
ClientGame.cs (in gameOne/Client)
function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdTestEcho()
{
echo("THIS IS A TEST");
}
function clientCmdShowVictory()
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game?",
"loadMyMission();",
"quit();");
}
Using the debugger and breakpoints I can tell that the collision code is executing, it's going to the client command lines on the server but it never gets to the client (or the breakpoints).
Simgroups are named right, Objects are the right objects, I tried deleting the dso's and recompiling.
Any ideas?
First, the code:
Logoitem.cs:
function TorqueLogoItem::onCollision(%this, %obj, %col)
{
if(%col.getClassName()$= "Player")
{
$client = %col.client;
%client.score++;
commandToClient(%client, "SetScoreCounter", 2);
commandToClient(%client, "TestEcho");
%obj.delete();
%logoCount = logos.getCount();
if(%logoCount>0)
{
return;
}
else
{
commandToClient(%client, 'ShowVictory', %client.score);
}
}
}
I added in a testEcho command as well as the original value to see if that was the problem.
ClientGame.cs (in gameOne/Client)
function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdTestEcho()
{
echo("THIS IS A TEST");
}
function clientCmdShowVictory()
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game?",
"loadMyMission();",
"quit();");
}
Using the debugger and breakpoints I can tell that the collision code is executing, it's going to the client command lines on the server but it never gets to the client (or the breakpoints).
Simgroups are named right, Objects are the right objects, I tried deleting the dso's and recompiling.
Any ideas?
#2
Where it reads:
Change this to read:
The $ indicates a global variable, and % indicates a local variable. $client is not the same as %client, and for the rest of the code block after the line I corrected, you are referencing it as %client, so you have no reference.
07/16/2006 (12:00 pm)
I can answer Dan's problem, at least.Where it reads:
$client = %col.client;
Change this to read:
%client = %col.client;
The $ indicates a global variable, and % indicates a local variable. $client is not the same as %client, and for the rest of the code block after the line I corrected, you are referencing it as %client, so you have no reference.
Torque Owner Michael Dimitrievski