Game Development Community

Chapter 5 error (first book->emaga5)

by Mike Rowley · in Torque Game Engine · 02/12/2006 (7:43 pm) · 11 replies

I have the following code in server.cs

function GameConnection::CreatePlayer(%this, %spawnPoint)
{
 if(%this.player > 0) //player should Not already have an avatar.
                      //if he does, that's a bad thing.
 Error("Attempting to greate an angus ghost!");
}
//create the player
%player=new Player()
{
dataBlock=HumanMaleAvatar; //defined in players/player.cs
client = %this //the avatar will have a pointer to its owners game connection
};
%player.setTransform(%spawnPoint); //where to put it.
//Update the camera to start with the player
%this.camera.SetTransform(%player.GetEyeTransform());
%player.SetEnergyLevel(100);
//Give client control of the player
%this.player = %player;
%this.setControlObject(%player);
}

There is an error calling out the ; in the following line:
dataBlock=HumanMaleAvatar; //defined in players/player.cs
client = %this //the avatar will have a pointer to its owners game connection
};

I commented out the ; to see if that was really the problem, but got the following in my error log:
Quote:
Compiling control/server/server.cs...
control/server/server.cs Line: 65 - Syntax error.
>>> Advanced script error report. Line 129.
>>> Some error context, with ## on sides of error halt:
client = %this //the avatar will have a pointer to its owners game connection

}## ##//;

%player.setTransform(%spawnPoint); //where to put it.

//Update the camera to start with the player
>>> Error report complete.

Can anyone tell me what the error is? I can't figure it out.
Thanks.

#1
02/13/2006 (6:41 pm)
Don't feel too bad. I had to skip the practical part of this chapter. My emaga5 locks up after a :

keyboard0 input device acquired.
%

Never figured out why. So I skipped it the practical part and moved on.
#2
02/13/2006 (6:55 pm)
Thanks. At least I know I'm not alone. Chapter 6 code works, and it's identicle, so I'll continue on.
#3
02/22/2006 (9:08 am)
Well, im pretty stuck aswell, tho i think your problem is that it shouldn't be dataBlock=HumanMaleAvatar; //defined in players/player.cs
but:
dataBlock = HumanMaleAvatar; //defined in players/player.cs
(small mistakes like forgetting spaces are really iritating)
tho i dont understand how you could continue with chapter 6, that chapter tells me that i should copy the contents of emaga5 to a new folder emaga6 and start modifying the game from there, tho i get the same error:
mouse0 input device acquired.
%
in the windows console window, but there are no errors printed in console.log! i cant find any mistakes i made, but there ought to be some since it simply doesnt work. also the entire splashscreen doesnt really work, there just is a black screen and when i press escape to exit, the screen asking whether id like to exit or not, which you program in in this chapter appears, but pressing the yes button doesnt work.

this is really iritating since i cant continue now, maybe someone knows where the error please help

thanks in advance
#4
02/22/2006 (9:31 am)
Karman you will have an easier time with this book if you use it as a resource and not a tutorial. The book is a bit congested with errors and it is using version 1.2 of the SDK. There are better tuts out there on the net and then you can use this book as a resource to go deeper into the meaning of the code.
#5
02/22/2006 (10:41 am)
Looks to me like your missing a ; here:

client = %this //the avatar will have a pointer to its owners game connection

needs to be:
client = %this; //the avatar will have a pointer to its owners game connection
#6
02/22/2006 (12:06 pm)
Good eye Owen. I missed that in his text. I checked the book, but it's showing in the book. :)
#7
02/24/2006 (7:14 pm)
Quote:(small mistakes like forgetting spaces are really iritating)

He did not forget any spaces there. They aren't required. Whitespace just adds to the readability of the code is all.
#8
02/24/2006 (7:34 pm)
Every line of code in torque script has a ; at the end.
How I got this to work was to install the demo from the cd. It works. kinda.
I'm still fighting my way thru all the mistakes.
#9
02/26/2006 (11:07 am)
Donald Harris

You said use the book as a resource there are better tutorials out there, could you list some sites? I did a google search and did not come up with any torque tuts. I did find information on game engines but no tuts
#10
02/26/2006 (12:59 pm)
Perhaps the resources located here provide good tutorials. There was something mentioned about a "MinApp" tutorial or something like that. Sounds like it's a pretty good start.

I think it's good that the book code has some bugs because it requires us to spend time debugging, and delving deeper into the inner workings of TGE, which in turn requires us to learn a bit more than the book actually teaches us. This is much better than just typing in the huge code dumps, which have so little explanation about their contents anyway.
#11
02/28/2006 (1:51 am)
Quote:I think it's good that the book code has some bugs because it requires us to spend time debugging
That's ok if the person already knows how to code, but if the person is totally new, and this is the first book he/she picks up, it isn't so good. The writer really should have made sure the book was correct and that the code was working properly.