Game Development Community

Followed Tutorial - Objects not deleting, score stays the same

by James O · in Torque Game Engine · 11/03/2007 (3:16 pm) · 8 replies

Hello All,
I purchased the Torque Game Engine a good while back, and I am just now getting into it. I followed the tutorial best I could, but the TorqueLogo objects aren't deleting, and the score is not changing. Any information would be great.

Thanks,
Jim

#1
11/04/2007 (6:19 am)
Can you show us the script changes you made? Try deleting all the .dso files, I've heard that can help.
#2
11/04/2007 (7:12 am)
Sounds like its not in your inventory ie maxinventory...
#3
11/04/2007 (7:23 am)
I added this to clientGame.cs in the client folder:
[code]function clientCmdSetScoreCounter(%score)
{
	ScoreCounter.setText("Score:" SPC %score);
}
function clientCmdShowVictory(%score)
{
	MessageBoxYesNo("You Win!","Would you like to restart the game ?","loadMyMission();","quit();");
}

Tom: Inventory? What exactly are you talking about?
#4
11/04/2007 (7:25 am)
My current logoitem.cs is:
//-----------------------------------------------------------------------------
// 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);
	}
};

Thanks in advance,
Jim
#5
11/04/2007 (8:00 am)
How did you add the logoitem to the mission? Did you select, in the world editor creator, "static shapes -> *path* -> torque_logo.dts"? If so, your object is just being created as a static shape - all that code you wrote isn't being applied to it, it just sits there. What you need to do instead is go to "shapes -> Items -> TorqueLogoItem". This will add the object with the datablock you declared in logoitem.cs, and the function where all your stuff happens.

Tom - the starter tutorial doesn't use the inventory system, so no worries there.
#6
11/04/2007 (8:23 am)
Daniel: Thanks, I did do what you said... TorqueLogoItem does not exist in shapes -> Items though, so how do I get it in there?

Thanks in advance,
Jim

[EDIT]
Shapes -> Items doesn't even exist X_x


[EDIT 2]
Problem solved. All I did was completely start over, and it was there this time. Thanks to everyone who helped.
#7
11/07/2007 (12:38 am)
Looks like it might have been the ; at the bottom of the onCollision function, just to try and clear that mystery up.
#8
11/07/2007 (7:38 am)
Oh man. Can't believe I didn't see that :P. Well, I do it often enough myself :P...