Game Development Community

Checkers Tutorial in 1.7.2 - networking

by Alex May · in Torque Game Builder · 03/23/2008 (5:19 pm) · 2 replies

I've been trying to do the checkers tutorial with version 1.7.2 and have gotten to step 2 where you're supposed to be able to test the networking after adding "Canvas.pushDialog(NetworkMenu);" to the onStartUp function and "$Game::UsesNetwork = true;" to the common.cs script. When I start the game, the network menu never comes up and I'd like to know why if anyone can help me out.

here's what I have for the onStartUp:

function onStartUp()
{
$mainScreen = mainScreenGui;
$mouseObj = new t2dSceneObject() {sceneGraph = $checkersScene;};

$none = 0;
$red = 1;
$blue = 2;
$redKing = 3;
$blueKing = 4;

$true = 1;
$false = 0;

$no = 0;
$yes = 1;

function redChecker::onLevelLoaded(%this, %scenegraph)
{
$redChecker = %this;
}

function blueChecker::onLevelLoaded(%this, %scenegraph)
{
$blueChecker = %this;
}

Canvas.pushDialog(NetworkMenu);
}

#1
03/24/2008 (4:13 am)
You're having problems because you've written the 2 onLevelLoaded functions within the onStartUp() function. You can't have functions within functions. The script file should look like this instead:

function onStartUp()
{
   $mainScreen = mainScreenGui;

   $mouseObj = new t2dSceneObject() {sceneGraph = $checkersScene; };

   // initialize the values for the checker boards
   $none = 0;
   $red = 1;
   $blue = 2;
   $redKing = 3;
   $blueKing = 4;

   // some helpful values
   $true = 1;
   $false = 0;

   $no = 0;
   $yes = 1;

   Canvas.pushDialog(NetworkMenu);
}

function redChecker::onLevelLoaded(%this, %scenegraph)
{
   $redChecker = %this;  
}

function blueChecker::onLevelLoaded(%this, %scenegraph)
{
   $blueChecker = %this;  
}

The console should be telling you when you have errors in script like this. You can pull up the console by pressing the CTRL ~ keys.
#2
03/24/2008 (8:15 am)
Ah, thanks
hopefully I'll be able to catch my own stupid mistakes now