Scoring issue in Getting Started Tutorial
by Norv Brooks · in Torque Game Engine · 12/27/2005 (4:57 pm) · 12 replies
I've completed the TGE 1.4 Getting Started Tutoria and everything is working fine except the Scoring. When I collide with the TorqueLogo it is deleted but the score does not increment. I've checked the scripting elements which I entered following tutorial in GameOne/server/logoitem.cs and GameOne/client/clientGame.cs several times for typing errors. Here's the last few lines from the Console output after launching and colliding with the first TorqueLogo:
*** Initial Control Object
Activating DirectInput ...
keyboard0 input device acquired.
GameOne/server/logoitem.cs (21): Unable to find object: "attempting to call function 'getCount
Mapping string: SetScoreCounter to index 12:
clientCmdSetScoreCounter: Unknown command.
Mapping string: ShowVictory to index 13:
clientCmdShowVictory: Unknown command.
keyboard0 input device unacquired.
Anybody got any thoughts on where to look?
Thanks,
Norv
*** Initial Control Object
Activating DirectInput ...
keyboard0 input device acquired.
GameOne/server/logoitem.cs (21): Unable to find object: "attempting to call function 'getCount
Mapping string: SetScoreCounter to index 12:
clientCmdSetScoreCounter: Unknown command.
Mapping string: ShowVictory to index 13:
clientCmdShowVictory: Unknown command.
keyboard0 input device unacquired.
Anybody got any thoughts on where to look?
Thanks,
Norv
About the author
#2
12/28/2005 (5:04 pm)
Jonathon - Thanks for the thought, but that didn't work for me.
#3
12/28/2005 (9:47 pm)
I did that tutorial about a month ago (or whenever 1.4 was released), and it worked for me. Just walk yourself through the steps again and see what you might have missed...
#4
This was the only area where I ran into trouble and it's because I skipped that one page (that'll teach me :)
12/28/2005 (10:21 pm)
Make sure your logo shapes are in a simgroup. I think this is where I ran into the problem because I skipped the section on placing interiors and they talk about setting up the group there. The count funtion is looking inside the simgroup "logos" to see how many objects are there. Your error SEEMS to indicate it can't find that group/object.This was the only area where I ran into trouble and it's because I skipped that one page (that'll teach me :)
#5
Norv
12/29/2005 (7:05 am)
James - Yes, I did think about the simgroup. I even created another simgroup, called it "torquelogos" , moved all the logo objects into it and changed the scripts accordingly. I still got the same errors. Thanks for the thought, though.Norv
#6
Maybe someone is able to spot the error. It's not the right object calling the function...
12/29/2005 (7:08 am)
Post you source of logoitem.cs around line 21.Maybe someone is able to spot the error. It's not the right object calling the function...
#7
12/29/2005 (9:30 am)
Also look earlier in your logs for something along the lines of "unable to instantiate XXX, not a member of YYYData class!". That would indicate that your datablock dependencies aren't in order, so the object's definition itself isn't loading.
#8
Here's the code I added to existing script "logoitem.cs":
ADDED FUNCTION
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();
echo(%logoCount);
if(%logoCount>0)
return;
//otherwise display Victory Screen
commandToClient(%client,'ShowVictory',%client.score);
}
}
Here's the script I created from scratch "clientGame.cs" :
NEW SCRIPT
//GameOne Client.cs
function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:"SPC %score);
}
function clientCmdShowVictory(%score)
{
MessageBoxYesNo("You Win!",
"Would you like to restart the Game?",
"loadMyMission();"
"quit();");
}
Thanks for your help!
Norv
12/29/2005 (11:15 am)
Stephen - I did not see any reference to "unable to instantiate..." in the Console log. I even ran FIND on "instantiate" with no findings.Here's the code I added to existing script "logoitem.cs":
ADDED FUNCTION
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();
echo(%logoCount);
if(%logoCount>0)
return;
//otherwise display Victory Screen
commandToClient(%client,'ShowVictory',%client.score);
}
}
Here's the script I created from scratch "clientGame.cs" :
NEW SCRIPT
//GameOne Client.cs
function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:"SPC %score);
}
function clientCmdShowVictory(%score)
{
MessageBoxYesNo("You Win!",
"Would you like to restart the Game?",
"loadMyMission();"
"quit();");
}
Thanks for your help!
Norv
#9
12/29/2005 (11:21 am)
Step through it and see if %client.score is actually incrementing. That will narrow things down. Also, is your simgroup (or whatever it's called) called logos? If not, make it that. Is your added function BELOW or WITHIN the brackets for the datablock? It should be after, not inside (the oncollision one that is). Is your control that holds the score in the GUI called ScoreCounter? If not, make it that.
#10
12/29/2005 (11:55 am)
In TorqueLogoItem::onCollision() there is a local variable %logos that is never initialized but is trying to be accessed. If its supposed to be a global variable defined somewhere else then you need to use the $ symbol instead of the % sybmol.
#11
Where it is referencing the logos object using it's name.
12/29/2005 (12:03 pm)
Having just looked at the tutorial it looks as though the suspect line is supposed to be:%logoCount = logos.getCount();
Where it is referencing the logos object using it's name.
#12
// Client scripts
exec("./client/optionsDlg.cs");
exec("./client/missionDownload.cs");
exec("./client/serverConnection.cs");
exec("./client/loadingGui.cs");
exec("./client/playGui.cs");
exec("./client/clientGame.cs"); Added this line
If so, I'm not seeing the problem.
Thanks for your help, Owen.
Norv
12/29/2005 (3:34 pm)
Owen - removing the "%" in front of logos.getCount() did fix that issue. It now will count down to "0" as I collide with the logos. However, the clientCmdSetCounter() and clientCmdShowVictory() functions are still "unknown" I'm wondering if the instruction to load "cllientGame.cs" in the main.cs script in the GameOne/client folder is the problem. The following is the //client script listing with my new line added:// Client scripts
exec("./client/optionsDlg.cs");
exec("./client/missionDownload.cs");
exec("./client/serverConnection.cs");
exec("./client/loadingGui.cs");
exec("./client/playGui.cs");
exec("./client/clientGame.cs"); Added this line
If so, I'm not seeing the problem.
Thanks for your help, Owen.
Norv
Torque 3D Owner Jonathon Stevens