ActivatePackage(control); question
by Camel Taylor · in Torque Game Engine · 08/03/2005 (12:48 pm) · 3 replies
OK minus some comments out of the book in the emaga4 and 5 examples now Im having a problem with package here it is
package control {
function OnStart()
//------------------------------------------------------------------------
// Called by root main when package is loaded
//------------------------------------------------------------------------
{
Parent::OnStart();
Echo("\n--------- Initializing control module ---------");
Exec("./initialize.cs");
InitializeServer(); // Prepare the server-specific aspects
InitializeClient(); // Prepare the client-specific aspects
}
function OnExit()
//------------------------------------------------------------------------
// Called by root main when package is unloaded
//------------------------------------------------------------------------
{
Parent::onExit();
}
}; // Client package
ActivatePackage(control); // Tell TGE to make the client package active
Now here is my question why must I make the activate the package? Wouldn't it just been simpler to skip the package control all togther and just leave the functions as be? Well I tried that I commented out the package control and the game just keeps crashing, oviously the package needs to be activated. So I defualt to what the books says " //tell TGE to make the client package active" I read that part in comments and I read that part in the book but I just dont it the only thing I can guess at what it does is that it forces the functions to execute without an actuall function call. Now Im sure I might be wrong with my hypothesis, but I'm tryig to get a deep understanding of the code and I'm not 100% clear what is happing with that part of the code.
So to sum it all up when you ActivatePackage(control); is execueted what is going on behing the curtains?
thank you in advance to any help I'm tying to get a deeper understaing of the code that I read.
package control {
function OnStart()
//------------------------------------------------------------------------
// Called by root main when package is loaded
//------------------------------------------------------------------------
{
Parent::OnStart();
Echo("\n--------- Initializing control module ---------");
Exec("./initialize.cs");
InitializeServer(); // Prepare the server-specific aspects
InitializeClient(); // Prepare the client-specific aspects
}
function OnExit()
//------------------------------------------------------------------------
// Called by root main when package is unloaded
//------------------------------------------------------------------------
{
Parent::onExit();
}
}; // Client package
ActivatePackage(control); // Tell TGE to make the client package active
Now here is my question why must I make the activate the package? Wouldn't it just been simpler to skip the package control all togther and just leave the functions as be? Well I tried that I commented out the package control and the game just keeps crashing, oviously the package needs to be activated. So I defualt to what the books says " //tell TGE to make the client package active" I read that part in comments and I read that part in the book but I just dont it the only thing I can guess at what it does is that it forces the functions to execute without an actuall function call. Now Im sure I might be wrong with my hypothesis, but I'm tryig to get a deep understanding of the code and I'm not 100% clear what is happing with that part of the code.
So to sum it all up when you ActivatePackage(control); is execueted what is going on behing the curtains?
thank you in advance to any help I'm tying to get a deeper understaing of the code that I read.
Torque 3D Owner Sean H.
the fact is you never have to use packages. you could simply give all your functions separate names and be done with it, but a good portion of the torque base and common code uses packages so youll want to understand them just to know whats going on.
but there are times where packages can come in handy. for instance, in my code when a player enters a vehicle, a package is activated which overrides some of the functions for capturing keyboard and mouse events and replaces them with others. when the player dismounts the vehicle, this package is deactivated and the functions return to their original state. doing this without using a package would require either remapping the keybinds, exec'ing another file, or forcing the player to use a different button set. packages are not necessary but they can definitely make things a little easier.