Game Development Community

Scoring problem in tutorial game

by Darlisa Riggs · in Torque Game Engine · 01/15/2006 (12:32 am) · 11 replies

I found another thread that dealt with scoring not working after following the demo tutorial, however, I'm unable to find the error. I even copied the code directly from the pdf file to make sure I had it correct.

I've checked all the names in the tree listing and they match the code. I would appreciate someone looking over the code to see if you see something I don't see.

Code in clientGame.cs

function clientCmdSetScoreCounter(%score)
{
	ScoreCounter.setText("Score:" SPC %score);
}

function clientCmdShowVictory(%score)
{
	MessageBoxYesNo("You Win!",
	"Would you like to restart the game?",
	"loadMyMission();",
	"quit();");
}

Code in logoitem.cs

//-----------------------------------------------------------------------------
// Torque Game Engine 
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

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

function TorqueLogoItem::onCollision(%this, %obj, %col)
{
	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);
	}
}

The onCollision works, the logo item disappears when the player touches it, but since the score isn't being incremented, the victory part is never shown.

About the author

Owner of CatBird Studios, home of the Alexa 2 figure for DAZ Studio and Poser.


#1
01/15/2006 (4:13 am)
Did you actually create the GUI for the Score:0?
#2
01/15/2006 (10:00 am)
Yes, the GUI has the "Score: 0" and it is named "ScoreCounter"
#3
01/15/2006 (10:20 am)
*deleted* Somehow got a double posting
#4
01/15/2006 (12:21 pm)
Did you rename each Logo a different name with no spaces?
#5
01/15/2006 (12:29 pm)
Yes, they are named logo1 through logo6
#6
01/15/2006 (1:08 pm)
Yes, they are named logo1 through logo6
#7
01/15/2006 (1:09 pm)
I reinstalled the engine, rebooted, and now it works ... go figure. Thanks for your help.
#8
01/15/2006 (4:55 pm)
I am having the exact same problem! HMM reboot huh. I'll try it!
#9
01/17/2006 (3:09 am)
Having a simlar problem, followed everything to the letter, even copy pasted after the 3rd attempt.. When I run into the logos, I just hit them. I'm assuming some how I ruined the actual logo script, any one have any ideas? Since I simply copy pasted, no room for typos?

Cheers chaps.
#10
01/17/2006 (5:13 am)
I had this problem too and I fixed it in an indeterminate way unfortunately, but I do have an idea of the steps...

I kept looking at my console.log to see what failed or gave warnings that was related to the logos.
I deleted the logo objects (keeping the simgroups) and also the example\GameOne\server\logoItem.cs.dso object so that it would get recompiled.

Somewhere along the way I lost the shapes\Items\TorqueLogoItem, so I copied it back into the \server directory from the original tutorial.base. I made a backup copy of my old collision function so I could paste it back into the copied torqueLogoItem.cs.

I also made sure that I was taking the Shapes\Items\TorqueLogoItem item and placing it on my map (and in the logos simgroup)

Make sure your item gets compiled correctly before you try debugging the rest. The console.log will tell you if there was a problem. Post yours up and we can try to help!
#11
05/29/2006 (4:38 pm)
A fix for this can sometimes be to use the DeleteDSOs.bat, it will go through and remove the pre-compiled files that will sometimes keep old and faulty data. It's always worth a shot.