Activate/deactivatePackage() bug?
by Edward F. Maurina III · in Torque Game Engine · 08/09/2004 (7:17 pm) · 2 replies
Hello all. I'm cruising along on EGTGE and have run into a whacko issue. I've got a set of methods for the guide which implements a simple GUI to load lessons without restarting missions. The premise is:
1. User right clicks in playgui - This pops up the lesson list.
2. User selects lesson from list and clicks OK.
3. Commands are executed to unload the current lesson and load a new lesson.
To easily clear up, I've done two things:
1. Put all new mission stuff in a special SimGroup titled 'LessonGroup'. I delete this on lesson change and that kills all of the current lesson's content.
2. I have created lesson packages, for example:
, subsequently, when I want to load a new lesson I do the following:
I felt, until now, that this was a rather elegant solution. However it isn't working. Instead, the first lesson I select works, but on subsequent tries regardless of what lesson I choose, only the first selected lesson loads. Now, I've verified that the string is getting passed properly to serverCmdLoadLesson(), and all is good right up to the activate. I've also verified (by adding comments to the engine) that the activatePackage() call is getting the correct package name. Still, it fails!
So, I've been goofing around and managed to reproduce the error meanwhile cutting all the GUI stuff out of the loop. I've made up an artificial test that does the same thing.
I'm pasting it here to see if some smart folks would take a look and give me feed back.
So, here is the code:
Now, to reproduce the error, do this:
1. Put this code in a file and load it from onServerCreated();
2. Start the kit
3. open the console and type:
whack0();
whack1();
4. This works.
5. Now type:
whack2(TP0);
whack2(TP1);
6. This does not work.
What do yo think?
Thanks in advances to those who try this.
PS - came back to clean up syntax and formatting.
1. User right clicks in playgui - This pops up the lesson list.
2. User selects lesson from list and clicks OK.
3. Commands are executed to unload the current lesson and load a new lesson.
To easily clear up, I've done two things:
1. Put all new mission stuff in a special SimGroup titled 'LessonGroup'. I delete this on lesson change and that kills all of the current lesson's content.
2. I have created lesson packages, for example:
package BasePackage {
function LessonPrep() {
// Prep for lesson
}
};
package lesson0 {
function ExecuteLesson() {
// Lesson 0 Stuff goes here
}
};
package lesson1 {
function ExecuteLesson() {
// Lesson 1 Stuff goes here
}
};, subsequently, when I want to load a new lesson I do the following:
// called from GUI
serverCmdLoadLesson( %client, %name ) {
// Remove any spaces
%LessonName = stripChars( %name, " ");
deactivatePackage(BasePackage); // Pops old lesson too!
activatePackage(BasePackage);
activatePackage(%LessonName);
LessonPrep();
ExecuteLesson();
}I felt, until now, that this was a rather elegant solution. However it isn't working. Instead, the first lesson I select works, but on subsequent tries regardless of what lesson I choose, only the first selected lesson loads. Now, I've verified that the string is getting passed properly to serverCmdLoadLesson(), and all is good right up to the activate. I've also verified (by adding comments to the engine) that the activatePackage() call is getting the correct package name. Still, it fails!
So, I've been goofing around and managed to reproduce the error meanwhile cutting all the GUI stuff out of the loop. I've made up an artificial test that does the same thing.
I'm pasting it here to see if some smart folks would take a look and give me feed back.
So, here is the code:
package TP0 {
function TestIt() {
echo("TP0::TestIt()");
}
function ExecuteLesson() {
echo("TP0::ExecuteLesson()");
}
};
package TP1 {
function TestIt() {
echo("TP1::TestIt()");
}
};
package BP {
function PrepIt() {
echo("BP::PrepIt()");
}
};
function whack0() {
%name = "TP0";
%testName = stripChars( %name, " ");
echo("Load package:" @ %name);
deactivatePackage(BP);
activatePackage(BP);
activatePackage(%testName);
PrepIt();
TestIt();
}
function whack1() {
%name = "TP1";
%testName = stripChars( %name, " ");
echo("Load package:" @ %name);
deactivatePackage(BP);
activatePackage(BP);
activatePackage(%testName);
PrepIt();
TestIt();
}
function whack2(%name) {
%testName = stripChars( %name, " ");
echo("Load package:" @ %name);
deactivatePackage(BP);
activatePackage(BP);
activatePackage(%testName);
PrepIt();
TestIt();
}Now, to reproduce the error, do this:
1. Put this code in a file and load it from onServerCreated();
2. Start the kit
3. open the console and type:
whack0();
whack1();
4. This works.
5. Now type:
whack2(TP0);
whack2(TP1);
6. This does not work.
What do yo think?
Thanks in advances to those who try this.
PS - came back to clean up syntax and formatting.
About the author
Recent Threads
#2
Thanks for the feedback. I've tried fixing this with the class namespace idea, both a scriptobject and a shapebasedata method. No dice. However, I see John had some luck, so I posted my latest code to his thread and asked for the specific solution he used (i.e. what class he used). This seems like a definte bug.
Thanks again!
08/10/2004 (7:48 pm)
Martin,Thanks for the feedback. I've tried fixing this with the class namespace idea, both a scriptobject and a shapebasedata method. No dice. However, I see John had some luck, so I posted my latest code to his thread and asked for the specific solution he used (i.e. what class he used). This seems like a definte bug.
Thanks again!
Torque 3D Owner Martin "Founder" Hoover
There is a way to script around some of the problems of the package problems, but I imagine just making your function names members of a class will help. In any case here is a thread that goes a bit deeper into it:
www.garagegames.com/mg/forums/result.thread.php?qt=19617