Game Development Community

Problem with package_test.cs in The Essential Guide...

by Darrel Cusey · in Torque Game Engine · 12/16/2005 (7:58 am) · 2 replies

I installed the TGE 1.4 and have been reading this documentation, and running the sample code in the console as I go along.

Everything is fine until I get to the package_test.cs in "The Torquescript Language" chapter (about page 25 when I printed it).

I exec the script and do not receive compile errors. However, when I execute the command test_packages(0); I get this error:

(0): Unable to find function test_packages


Here's just the first few lines of the code I entered for package_test.cs -- I copied the code directly from The Essential Guide doc.

The full code is larger than the 4096 max character length for posting, so I'm just posting the first few lines of it, so people know which one I'm talking about:

//
// Define an initial function: demo()
//
function demo()
{
echo("Demo definition 0");
}

//
// Now define three packages, each implementing
// a new instance of: demo()
//

//

#1
12/16/2005 (9:08 am)
Is "test_packages" the name of your package or the name of a function inside that package? If it is the name of the package then the error you get explains it all, it' not a function. In the example code above you have a function in the package called "demo", try calling that in the console, you should get the echo back if your package is loaded correctly. A package isn't an object, it allow you to override functions and create new functions that are only available when the package is loaded. That reminds me, you said you exec'd the package file with no problems, have you loaded the package? I believe the command is loadpackage(yourpackagename);. Packages can be confusing at first but can help you out big time down the road.
#2
12/17/2005 (7:28 pm)
The solution turned out to be quite a bit more complex than I thought -- just doing

loadpackage(DemoPackage1);
loadpackage(DemoPackage2);
loadpackage(DemoPackage3);

...didn't solve it.

The complete solution was identified and documented by other members as seen in the posts below:

http://www.garagegames.com/mg/forums/result.thread.php?qt=21074
http://www.garagegames.com/mg/forums/result.thread.php?qt=35463

...so, it looks like this is a re-occurring problem and people (like me) who really do read every line of documentation and try to run every sample program are the ones who keep running into this...

Maybe The Essential Guide and all the various channels on the GG website where this tut is echoed could fix this before it claims another victom?

Here are the places I could find this tutorial (besides in The Essential Guide) that still were not corrected:

http://www.garagegames.com/docs/tge/general/ch05s02.php
http://tdn.garagegames.com/wiki/TorqueScript