Game Development Community

Deprecated ScriptClass in Checkers Demo

by Dan Schlusselberg · in Torque Game Builder · 12/28/2006 (4:46 am) · 18 replies

The checkerboard.cs script begins with:

new ScriptClass(CheckerBoard);

which generates an error in the compiler: Unable to instantiate non-conobject class ScriptClass

What is the correct way to instantiate the object?

Thanks

Dan

#1
12/31/2006 (4:31 pm)
Dan, I examined my own completed Checkers demo and the GarageGames games/checkersdemo/gameScripts/checkerBoard.cs. Each is coded just as you have it above, and neither generates this error message when compiled. Very mysterious. For your reference, here is my line:

new ScriptClass( CheckerBoard ) ;

Hope you extricate yourself somehow. Maybe you have non-printing characters in the line?
#2
12/31/2006 (6:01 pm)
Dan,
You should be able to get away with changing your ScriptClass, which was deprecated in 1.1.3, to ScriptObject which provides the same namespace linking support that ScriptClass did previously.

Cheers,
-Justin
#3
01/01/2007 (11:45 am)
OK I tried ScriptObject as follows:

new ScriptObject(CheckerBoard);

as the first line in checkerboard.cs

and got this error in the console of TGB when trying to play the game:

Error: cannot change namespace parent linkage for CheckerBoard from t2dStaticSprite to ScriptOjbect

Thanks for your help.

Do you have the checkerboard demo scripts available - I have found numerous other errors in the documentation tutorial scripts.
#4
01/05/2007 (12:04 am)
I think the problem Dan is experiencing has to do with the way classes are named in the project. The following gives fragments of code relating to the issue. When I change the ScriptClass keyword to ScriptObject, as suggested by Justin, I get the very same error message. The problem appears to be that the clientCheckerBoard declaration sets Class CheckerBoard's parent to t2dSceneGraph, and this conflicts with a later statement "new ScriptObject( CheckerBoard )".

%levelContent = new t2dSceneGraph() {
...
new t2dStaticSprite(clientCheckerBoard) {
imageMap = "Checkers_boardImageMap" ;
class = "CheckerBoard" ;
boardLayer = "CheckerTileLayer" ;
...
};
...
};

new ScriptClass( CheckerBoard ) ;

Now that I am attempting to explain matters. I realize that I am rather confused about Torque's way of dealing with OOP.
#5
01/08/2007 (10:05 pm)
I changed the first line in checkerboard.cs to: new ScriptObject(CheckerBoard);

and on line 105 I Changed it

from: midSpot = %this.getPiece(%newX, %newY);

to: %midSpot = %this.getPiece(%newX, %newY);

I didn't have any errors but when I ran the game it didn't populate the checkers and a message

common/gameScripts/client/message.cs(13): Unable to find function on ServerMessage
#6
01/09/2007 (5:04 am)
I came on after ScriptClass was already ancient, but I think you used to have to define a class before you used it. You should be able to just delete that whole scriptclass 'new' statement without any problems.
#7
02/01/2007 (10:07 pm)
I recently purchased TGB and was going through the tutorials and I cant seem to get past section Checkers Tutorial - Part 4. I get 100 + errors in the clientCheckers.cs unable to find objects. I have tried the fixes posted above with no luck. Is there an updated fix that someone could point me to?

Thanks in advance.
#8
02/05/2007 (9:58 am)
I rather think that Dan's original question does not relate to Charles's problem.

But Charles, if you are still having trouble with the tutorial, why not start a thread about it? You might want to copy the relevant lines from console.log into your post so that folks can help you more effectively.
#9
02/05/2007 (10:41 am)
Actually there are other errors in the Checkers tutorial - but I figured out how to fix them myself. I think the checkers demo was originally written for an earlier version of TGB (Perhaps something called T2D) and was never updated.

I have asked if anyone had a working demo with source code, but nobody has replied.

I still don't have a complete working version. Are there other network multiplayer demos? That is the best reason to learn the checkers tutorial - to see how multiplayer works in TGB.
#10
02/05/2007 (12:23 pm)
I think that is the problem with mine as well, my version of TGB not being compatable with the tutorial. Maybe someone will post and updated tutorial or possibly the code to fix this one.
#11
02/05/2007 (4:21 pm)
I worked my way through the tutorial, but I bashed it up pretty good in the process. Now it has bulked up into this monster 50Mb folder. But it is definitely up to date and free of the bugs in the original tutorial. Although I probably introduced plenty of my own.

I had wanted to post it to the GarageGames site along with some explanatory text. This would be my first contribution along these lines. But I am unclear how to do this: it would involve uploading a .zip file to the GarageGames site, and I think more privileges are required than I have.

Anybody have any ideas?
#12
03/13/2007 (11:18 am)
I too recently purchased TGB Pro. I completed the fish tutorials ok, but ran into some of the same problems with the Checker Demo. I corrected the obvious typo: midSpot to %midSpot, but upon reaching section 4.3 Test it!, the Connection GUI did not disappear and the board was not populated with pieces. I tried changing new ScriptClass(CheckerBoard) to new ScriptObject(CheckerBoard), as suggested above, but, although it didn't generate any errors, it did not solve the problem. I laboriously reconstructed the tutorial from the start, in case I had accidentally introduced any spurious non-displayable characters, but I had exactly the same results. I don't have a solution, but I just wanted to add my experiences to the pot, as it were.
#13
04/14/2007 (1:19 am)
I think the problem with changing ScriptClass to ScriptObject is that the (forgive me if my terminology is incorrect, I'm new to this as well) namespace CheckerBoard is already assigned somewhere else in the code. I renamed every instance of CheckerBoard in the checkerboard.cs file to CheckerBoard2 and the new ScriptObject(CheckerBoard2) works just fine.

It still doesn't seem to initialize the pieces or make the Network dialog go away, but I've figured out how to make the NetworkMenu go away.

Canvas.popdialog(NetworkMenu);

Now I just need to figure out why it's not creating the checkers pieces on the board. . . I suspect it doesn't have anything to do with the code in checkerboard.cs.
#14
04/19/2007 (4:10 pm)
I actually think you need to define CheckerBoard as a SimObject. That way it can be used as a t2dStaticSprite.

I think the problem with populating the board is due to $redChecker and $blueChecker never being defined.
// create a new piece as a clone of our stored piece
%piece = $redChecker.clone(true);
%piece.setName("redPiece" @ %num);
Greping the tutorials source code does not show $redChecker ever being defined. Or is it defined and I am overlooking it?
#15
04/19/2007 (4:22 pm)
Not ever being instructed what a SimObject is in any of the three tutorials so far, I wasn't sure if that was correct. I'll have to test it out.

You are right about $redChecker and $blueChecker not being defined. I figured this out a couple of days ago and managed to get the server to populate the board when a client connected to it by giving those pieces names in the Level Builder. However, the client does not populate the board with checkers pieces. I checked the console and it gives a lot of errors, probably stemming from the fact that I don't have $CheckerBoard defined as a SimObject. I thought it was weird that my server was populating the graphics but the client wasn't, so I tried running the server from the built project instead of from within the Level Builder and the server ended up with the same errors as the client and did not display the graphics.

I just updated the code to use a SimObject and built it. I'm happy to announce that the checkerboard population was a success for both server and client. Now I can start working on the next part of the tutorial.

Thanks so much Chaim! You may not realize how much frustration you've saved me from trying to figure this out for the past week!

EDIT: Maybe I should also note that I had to rename the $redChecker and $blueChecker to $rChecker and $bChecker because when I tried to name them fully spelled out in the Level Builder, it would automatically capitalize them--making them named the exact same thing as their respective Class.
#16
04/19/2007 (6:03 pm)
Next problem seems to be bug. common/gameScripts/client/messages.cs::defaultMessageCallback() is called and all that function does is call onServerMessage(detag(%msgString)), but that is undefined. A peak at TDN shows that this function is not available in TGB113. I will inquire in the private forums about this matter.
#17
04/30/2007 (12:39 pm)
The undefined onServerMessage() error in the console doesn't prevent the CheckersDemo from working, but I imagine it isn't good programming practice to leave errors/warnings in there.
#18
03/17/2009 (1:17 am)
:)