Game Development Community

GPGT Chapter 5 - Issues and Questions

by Edward F. Maurina III · in Torque Game Engine · 05/16/2006 (10:41 pm) · 7 replies

Hello All. This thread is dedicated to any questions or issues that you may find in this chapter.

If you have issues and questions for other chapters, please post them in the appropriate thread:
Chapters 1 & 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14

GPGT Support Page
Appendix E. Maze Runner Lessons (Steps Only) - Covers Mac and Windows
OSX Executable - Use for GPGT Lesson Kit and MazeRunner

#1
12/07/2006 (7:02 am)
Hello, I am at 5.1.4 and when asked to put in the code for lesson ts01();
I get the error message Register object failed for object Superguy of class Player. I did it both in the script console sample and inside the mission area. How can I fix this??
#2
12/14/2006 (9:29 pm)
Stacey,

Hi. I'm sorry it took me so long to answer. Here are a couple of different answers.

Answer #1 - To see the code run.

This example is already provided in the file "~/gpgt/SampleScripts/stsAdvancedScripting.cs".

So, to see it run, do the following:
1. Run the GPGT Lesson Kit
2. Start the mission '3D Lessons'
3. Open the console (~)
4. Type: ts01();


Answer #2 - To type the code in for yourself and see it run that way.


1. Locate the file from step #1 and open it.
2. Locate this file: "~/gpgt/server/scripts/game.cs"
3. Open the file in your favorite text editor.
4. Locate the file: "~/gpgt/SampleScripts/stsAdvancedScripting.cs"
5. Open it in your favorite editor and then locate this code:
////
//		TS01
////
function ts01() {
   if( ! sscls() ) return;

   %obj = new Player( SuperGuy ) 
   {
      datablock = basePlayer;
   };

   echo( %obj.getName() ); // will echo ==> SuperGuy

   echo( %obj.getClassName() ); // will echo ==> Player

   echo ( %obj.getDatablock().getClassName() ); // will echo ==> PlayerData

   echo ( %obj.getDatablock().getName() ); // will echo ==> basePlayer

   %obj.delete();

}

6. Select the entire snippet of code and copy it to your copy buffer (usually CTRL+C in Windows tools).
7. Go back to "game.cs"
8. Paste (CTRL+V) the copy buffer contents to the very end of the "game.cs" file
9. Edit the pasted code so it looks like this:
function myTest() {
   %obj = new Player( SuperGuy ) 
   {
      datablock = basePlayer;
   };

   echo( %obj.getName() ); // will echo ==> SuperGuy

   echo( %obj.getClassName() ); // will echo ==> Player

   echo ( %obj.getDatablock().getClassName() ); // will echo ==> PlayerData

   echo ( %obj.getDatablock().getName() ); // will echo ==> basePlayer

   %obj.delete();
}

10. Save "game.cs"
11. Start the mission '3D Lessons'
12. Open the console (~)
13. Type: myTest();


Explanation Of What Might Have Gone Wrong For You

I am unable to reproduce your error (without changing the code so that it is wrong), and I'm not 100% sure from your note above whether you were running the FPS starter kit, or the GPGT Lesson Kit.

However, if I were to wager a bet, I would say that you're not running the GPGT lesson kit, or that you've modified it so that the datablock definition for basePlayer is not getting loaded.

Why do I guess this?

"Register object failed for object Superguy of class Player" is the engine's way of telling you that it could not create the object you asked it to make. One way this can happen is if you try to make an object that requires a datablock and the datablock is not present.

You can test for this by doing the following:

1. Run the GPGT Lesson Kit
2. Start the mission '3D Lessons'
3. Open the console (~)
4. Type: echo( isObject( basePlayer ) ) ;

If this prints 1, then the the basePlayer datablock is present. If it prints 0, then it is not.

If it is not present, and if you are running the GPGT lesson kit, then you should look back through the console log and see if there was a problem loading the player.cs and blueguy.cs files.

Look for this in your log:
Quote:
******************** Loading Volume 1 Base Classes

... several lines, then ...

Compiling gpgt/server/scripts/GPGTBase/Player/Player.cs...
Loading compiled script gpgt/server/scripts/GPGTBase/Player/Player.cs.
Compiling gpgt/data/BlueGuy/player.cs...
Loading compiled script gpgt/data/BlueGuy/player.cs.


Closing Notes
1. Please be sure to run the GPGT Lesson Kit.
2. Try the steps in answer #1.
3. You may notice that the code has a minor mismatch from the book.
Instead of this
function ts01() {
   if( ! sscls() ) return;

   %obj = new Player( SuperGuy ) 
   {
      datablock = basePlayer;
   };

   echo( %obj.getName() ); // will echo ==> SuperGuy

   echo( %obj.getClassName() ); // will echo ==> Player

, you may have:
function ts01() {
   if( ! sscls() ) return;

   %obj = new Player( ) 
   {
      datablock = basePlayer;
   };

   echo( %obj.getClassName() ); // will echo ==> Player

If so, you'll need to correct the definition (in the file), to match the book.

4. If none of this helps, please post again with some additional details on what you are trying.

Again, sorry for the delay. I hope this helps.

www.hallofworlds.com/how.ico Hall Of Worlds - For Gamers
EdM|GPGT
#3
12/15/2006 (8:24 am)
Oh okay. I was trying to type the code given to me inside the GPGT KIT Sample Console that is where I kept getting the error. After I moved it to the game.cs it worked fine. Thx!! :D
#4
01/04/2007 (9:46 pm)
Ok Ed,

So if we want to go ahead and input the code ourselves for each sample snippet we can just extract it from the underlying script file, paste it in the game.cs file and run it like that, if so I think this is a better way than using the sample console.

Shakey
#5
01/05/2007 (3:36 pm)
@Shakey,

Hi. I think there is some confusion here:

1. All of the scripts in the book that have a comment like

//ts123();

some code ...

or
//bt123();
some code ...

can simply by run by loading th GPGT Lesson Kit, running either of the missions, openning the console and typing

ts123();

or

bt123();

or whatever the comment says.

2. The Sample script console is designed for lecturing (i.e. for teachers). You can type in ad hoc scripts and run them (excluding anything requiring the server to be active). Additionally, the kit comes with a bunch of ready made examples that can be run in the console.

Simply do the following:

1. Run the GPGT Lesson Kit
2. Start the Sample Script Console
3. Make sure all the checkboxes at the left are checked (not required)
4. Click the 'Load' button
5. Select any script under gpgt -> ScriptSamplerSamples\
For example, you could load the first one 000_echo.cs
6. If you clicked the checkboxes, this sample will auto run. The code is on th left and the output is on the right.
7. Now, you can run in lecturew mode by clicking 'Next >>' to get to the next example (it auto runs), or '<< Prev' to go back one example.

I hope this clarifies things.

www.hallofworlds.com/how.ico Hall Of Worlds - For Gamers
EdM|GPGT
#6
10/09/2008 (3:26 am)
Hi from Greece! Newbie here! Just a question! I make changes in "myTest" script but I have to restart gpgt to "compile" the "new" function! Can I do that without restart kit?
#7
12/27/2008 (12:51 pm)
I know this is an old question, but I'm answering it anyways...


Yes, but the best way is to restart the kit. If you read my second book, I talk about making reloaders to load modified scripts. Also, if you use the Torsion IDE it is possible reload scripts you modify in the editor.

-Ed