Getting Started" tutorial problems
by Chris Harpan · in Torque Game Engine · 04/12/2007 (1:53 pm) · 5 replies
Well, I've done a few searches, and couldn't find the answer already here on the forums, so here goes.
I'm working with TGE 1.5.1, just reinstalled. I've gotten everything working in the "Getting Started" tutorial, except that as soon as you collide with any of the logo objects, you get the game message to start over.
Here's the code from C:\Torque\TGE_1_5_1\example\GameOne.base\server\logoitem.cs
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);
}
}
And here is the code from C:\Torque\TGE_1_5_1\example\GameOne.base\client/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();");
}
If it's possible, can someone check this over and see if I'm doing something wrong?
I'm not familiar enough yet with Torsion to check it there and know that I've found something wrong.
Thanks in advance....
I'm working with TGE 1.5.1, just reinstalled. I've gotten everything working in the "Getting Started" tutorial, except that as soon as you collide with any of the logo objects, you get the game message to start over.
Here's the code from C:\Torque\TGE_1_5_1\example\GameOne.base\server\logoitem.cs
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);
}
}
And here is the code from C:\Torque\TGE_1_5_1\example\GameOne.base\client/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();");
}
If it's possible, can someone check this over and see if I'm doing something wrong?
I'm not familiar enough yet with Torsion to check it there and know that I've found something wrong.
Thanks in advance....
About the author
#2
Thanks in advance
04/15/2007 (7:14 pm)
Can someone show me how to do this same logo - score technique but with a trigger instead of the logoItem?Thanks in advance
#3
04/16/2007 (6:12 am)
Do it in the onEnter function for the trigger instead of the onCollision for the logo.
#4
function TempleOfEvilTrigger::onEnterTrigger( %this, %trigger, %obj )
{
%client = %obj.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);
echo( "The player has just entered the Temple of Evil! - Not the smartest move!");
// This method is called whenever an object enters the %trigger
// area, the object is passed as %obj. The default onEnterTrigger
// method (in the C++ code) invokes the ::onTrigger(%trigger,1) method on
// every object (whatever it's type) in the same group as the trigger.
Parent::onEnterTrigger( %this, %trigger, %obj );
}
Thanks for the help MB. I know it seems small but this opens alot conceptually for me.
04/16/2007 (10:04 am)
Thanks, I guess I just needed someone to shove me over the edge to try it. I'm a newb scripter so this if for the other newbs. Here's what the onEnter function should look like as MB suggested.function TempleOfEvilTrigger::onEnterTrigger( %this, %trigger, %obj )
{
%client = %obj.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);
echo( "The player has just entered the Temple of Evil! - Not the smartest move!");
// This method is called whenever an object enters the %trigger
// area, the object is passed as %obj. The default onEnterTrigger
// method (in the C++ code) invokes the ::onTrigger(%trigger,1) method on
// every object (whatever it's type) in the same group as the trigger.
Parent::onEnterTrigger( %this, %trigger, %obj );
}
Thanks for the help MB. I know it seems small but this opens alot conceptually for me.
#5
how bout this part, I want a tick to register a score the same way onEnter works. But this doesn't seem to be working what am I doing wrong?
function TempleOfEvilTrigger::onTickTrigger( %this, %trigger, %obj )
{
%client = %obj.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);
echo( "The player is still in the Temple of Evil! - Calling all monsters!");
// This method is called every tickPerioMS, as long as any
// objects intersect the trigger. The default onTriggerTick
// method (in the C++ code) invokes the ::onTriggerTick(%trigger) method on
// every object (whatever it's type) in the same group as the trigger.
// You can iterate through the objects in the list by using these
// methods:
// %this.getNumObjects();
// %this.getObject(n);
Parent::onTickTrigger( %this, %trigger );
}
how do I make this work?
Thanks in advance
04/16/2007 (10:40 am)
MB, how bout this part, I want a tick to register a score the same way onEnter works. But this doesn't seem to be working what am I doing wrong?
function TempleOfEvilTrigger::onTickTrigger( %this, %trigger, %obj )
{
%client = %obj.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);
echo( "The player is still in the Temple of Evil! - Calling all monsters!");
// This method is called every tickPerioMS, as long as any
// objects intersect the trigger. The default onTriggerTick
// method (in the C++ code) invokes the ::onTriggerTick(%trigger) method on
// every object (whatever it's type) in the same group as the trigger.
// You can iterate through the objects in the list by using these
// methods:
// %this.getNumObjects();
// %this.getObject(n);
Parent::onTickTrigger( %this, %trigger );
}
how do I make this work?
Thanks in advance
Torque 3D Owner mb