Game Development Community

Getting Started tutorial: clientGame.cs file not compiling

by Mike Berg · in Torque Game Engine · 06/23/2006 (7:24 am) · 11 replies

I'm very new, and am getting stuck on the very last phase of the GettingStarted.pdf tutorial that comes in the "example" folder (1.4).

I've followed every step to the letter, but my clientGame.cs file does not seem to be getting touched. A .dso file does not appear for it, which means that the sample "game" does not work at all.

I've tried looking through the forums, and the closest thing I found was [url="http://www.garagegames.com/mg/forums/result.thread.php?qt=4736"]this thread[/url]. I tried adding the compile code at the bottom of the thread into my "GameOne/main.cs" file, like so:

function onStart()
{
   // Initialize the client and the server
   Parent::onStart();
   CompileFiles();
   compileCSFiles();
   compileGuiFiles();
   initServer();
   initClient();
   $Editor::newMissionOverride = "GameOne/data/missions/GameOneMission.mis";
}

function onExit()
{
   // Save off our current preferences for next time
   echo("Exporting prefs");
   export("$Pref::*", "./prefs.cs", False);
   Parent::onExit();
}

}; // Client package
activatePackage(ttb);

//-----------------------------------------------------------------------------

function CompileFiles(%dir)
{
   compileCSFiles(%dir);
   compileGuiFiles(%dir);
}

function compileCSFiles(%dir)
{
   %search = %dir @ "/*.cs";
   for(%file = findFirstFile(%search); %file !$= ""; %file = findNextFile(%search))
      if(fileBase(%file) !$= "config.cs" && fileBase(%file) !$= "prefs.cs")
         compile(%file);
}

function compileGuiFiles(%dir)
{
   %search = %dir @ "/*.gui";
   for(%file = findFirstFile(%search); %file !$= ""; %file = findNextFile(%search))
      compile(%file);
}

//-----------------------------------------------------------------------------

I'm not sure if that's in the right place or not. Any help? It's a little frustrating being stuck on the first step of the journey!

I am on Mac OS X 10.4.6, using the most recent download of Torque. I'm using [url="http://www.barebones.com/products/textwrangler/"]TextWrangler[/url] to edit the files, but have tried it in XCode too.

#1
06/23/2006 (4:24 pm)
Open up the console.log file (in the same dir as the .exe) and search for 'clientgame.cs'.

If you find it there's probably an error.

If you don't find it, it's not getting executed. If this is the case you need to add an
exec("[path]/clientGame.cs")

in a script that is getting executed (I think init.cs).
#2
06/23/2006 (7:41 pm)
Thanks Juan, that allowed me to pinpoint the bad syntax on a specific line... but my original problem (collision detection not working) is still with me. The issue is that I cannot run into the Torque logos and "pick them up", basically the functions that are called in clientGame.cs.

Looking in the log again, I see this line, under "*** Phase 1: Download Datablocks & Targets":
Warning: shape GameOne/data/shapes/3dtorquelogo/torque_logo.dts collision detail 1 (Collision-1) bounds exceed that of shape.

Could that have something to do with it?
#3
06/23/2006 (9:29 pm)
Search for tide controller that has a demo of gameone with it. I download while back, everything work good.

Here the link.
http://www.includingjudas.com/clint/TidalExample.zip
#4
06/23/2006 (10:39 pm)
Make sure the player (in its datablock definition) has a maxInv[_insert_item_datablock_here] = MaxInventory statement.

For example, the datablock definition for the logo is this:

//----demo/server/scripts/scene.cs
datablock ItemData([b]Logo[/b])
{
   // An item is used
   category = "Misc";
   shapeFile = "~/data/shapes/logo/torque_logo.dts";
};

What you would need is this in the player's datablock definition:
//----demo/server/scripts/player.cs
datablock PlayerData(MyPlayerData)
{
    shapeFile = "~/data/shapes/player/player.dts";
    [b]maxInv[Logo] = 10;[/b]
}

This says that if you create a Player (Player() object) using the MyPlayerData datablock (new Player() { datablock=MyPlayerData;}), it will be allowed to pick up 10 Logos.

I once had a hard time with this too with it not working, but come to find out, I had never exec'd inventory.cs.

That's why usually when something doesn't work the way I think it should work, I delete all DSOs (so that I'm not going off of a previous, working DSO if the new .cs failed to compile), search console.log for 'syntax', 'unable', 'could not', etc...

With regards to the torque logo collision bounding box exceeding the shape, I highly doubt that's the problem. I think I have a couple dts's that Torque spits out errors for but never really prevents me from getting what I need to do done.

I'm still pretty new to this also...99% of my posts are questions!
#5
06/24/2006 (5:10 am)
I had the same issue, and I missed a '}' in my script. Also did you put your logos in a sim group and give it the correct name? Also posting your script exatcly would help.
#6
06/24/2006 (6:29 am)
Juan, thanks for the detailed response... though I think we might be working from different tutorials. The PDF I'm working from uses "tutorial.base" as the root folder, not "demo". Also, there is no mention of creating an "inventory.cs" file, and does not use an inventory to track the number of logos you've picked up. They simply count how many logos are left on the map, and if it's greater than zero, it keeps going. If it's zero, you get a "victory" screen. Regardless, I'm not getting the collision detection at all, so I'm not able to "pick up" the logos in any case.

Rick, yes, my logos are in a "logos" sim group, and I'm not getting any more syntax errors in my console, and I've looked everything over, so I'm pretty sure it's not syntax. [url="http://www.door62.com/temp/MikeBergTorqueProblem.zip"]Here's the entire project folder and pdf I'm using[/url]. The player is set up to start right in front of a logo.
#7
06/24/2006 (6:28 pm)
Oops, just realized I'm going off of the demo that comes with TSE.

You sure you're not getting inside of the onCollision()? You can throw an
echo("Logo onCollision:" SPC %obj.getClassName());

as the first line of the onCollision, or you can execute a
trace(1);

to trace function execution. Be aware that using the mouse calls thousands of pitch() and yaw() calls so try not to use the mouse!

I was able to retrieve your zip and didn't see anything wrong at first eyesight. Could you post a console.log?
#8
06/24/2006 (6:50 pm)
Juan,

[url="http://www.door62.com/temp/console.zip"]Here's my console[/url].

I tried both of the things you mentioned, and still get no result. This is probably going to be something rediculous, isn't it...?
#9
06/24/2006 (7:11 pm)
Yea, still didn't see anything wrong; gonna try out your stuff when I get to work to see if it actually works for me.
#10
06/25/2006 (3:10 am)
OK, Mike Berg, I figured it out. The reason why they're not getting picked up is because you added them to the mission by locating it under the "Static Shape" tree (creates it as a TSStatic), when it needs to be from the "Shapes" tree (creates it as a StaticShape)...yes the names do kind of conflict with each other but that's why nothing happens. The TSStatic doesn't know anything about a datablock and is just "there" for you to see and bump into. StaticShape actually uses the datablock so it gets all the good stuff the datablock has to offer.

img81.imageshack.us/img81/8612/g9pr.jpg
//---NO!!!-----
   new TSStatic() {
      position = "62.7043 -423.795 13.4702";
      rotation = "1 0 0 0";
      scale = "1 1 1";
      shapeName = "~/data/shapes/3dtorquelogo/torque_logo.dts";
   };

   //---YES!!!------
   new StaticShape() {
      position = "62.7043 -423.795 13.4702";
      rotation = "1 0 0 0";
      scale = "1 1 1";
      dataBlock = "TorqueLogoItem";
   };
#11
06/25/2006 (7:23 am)
Success! Juan, thanks so much for taking the time!! I knew it would be something simple...