Totally Baffled!!!!
by Gonzo T. Clown · in Torque Game Engine · 04/03/2004 (11:39 am) · 16 replies
Ok, so far, I have never had a problem with scheduling, and suddenly now I do. Can anyone explain to me why this is occuring?
This works perfectly....
This one fails completely and fires off it's function the instant it's created.
The ONLY differences between the are their targets "CTF::endMatch()" and "CTF::twoMinuteWarning()". I don't get it.
????
This works perfectly....
$CTF::endMatch = schedule(120000, 0, CTF::endMatch());
This one fails completely and fires off it's function the instant it's created.
$CTF::endMatch = schedule(120000, 0, CTF::twoMinuteWarning());
The ONLY differences between the are their targets "CTF::endMatch()" and "CTF::twoMinuteWarning()". I don't get it.
????
About the author
#2
edit: Yeah use the object version then and it will probably fix it.
04/03/2004 (12:16 pm)
Not that it answers your question, but why aren't you using the object version of schedule? Seems perfectly suited to the way you are trying to use it.CTF.schedule(12000, "twoMinuteWarning");
edit: Yeah use the object version then and it will probably fix it.
#3
And to intercept it, I changed this....
to this to divert to the new schedule...
Thats when everything went wrong.
04/03/2004 (12:17 pm)
I see, it's not an object. Its just a global schedule I'm setting. This all worked perfectly untill I tried to intercept the end of the game with a two minute warning like this....function CTF::twoMinuteWarning()
{
echo("TWO MINUTE WARNING ACTIVE");
$CTF::endMatch = schedule(120000, 0, CTF::endMatch());
}And to intercept it, I changed this....
$CTF::endMatch = schedule(%time, 0, CTF::endMatch());
to this to divert to the new schedule...
$CTF::endMatch = schedule(%time, 0, CTF::twoMinuteWarning());
Thats when everything went wrong.
#4
I'm 99% sure you can store the return from this one just like the other version as well. I just don't here.
04/03/2004 (12:19 pm)
Heh sorry had to edit it 400 times to get it right. I had to reference an example of my own to jog my memory. Here is an example of using the object version in the Simple Chat system from my resource:$PollTime = 60; // time, in minutes, between checks to see if the server is connected to any clients
chatConnection.schedule($PollTime * 60 * 1000, "checkOnline");
echo("Sechedule set");I'm 99% sure you can store the return from this one just like the other version as well. I just don't here.
#5
try theses.
$CTF::endMatch = schedule(120000, 0, CTF::twoMinuteWarning());
to
$CTF::endMatch = CTF.schedule(120000, 0, "twoMinuteWarning");
$CTF::endMatch = schedule(120000, 0, CTF::twoMinuteWarning());
to
$CTF::endMatch = CTF.schedule(120000, 0, "twoMinuteWarning");
get it? thats your problem by the looks of it. hope this helps
04/03/2004 (12:26 pm)
Ya from bascily anything with :: in the function well not work like you were doing.try theses.
$CTF::endMatch = schedule(120000, 0, CTF::twoMinuteWarning());
to
$CTF::endMatch = CTF.schedule(120000, 0, "twoMinuteWarning");
$CTF::endMatch = schedule(120000, 0, CTF::twoMinuteWarning());
to
$CTF::endMatch = CTF.schedule(120000, 0, "twoMinuteWarning");
get it? thats your problem by the looks of it. hope this helps
#6
04/03/2004 (12:29 pm)
Gonzo, CTF is an object. What i'm saying is use the CTF object to call the "object version" of schedule. IE instead of making a global schedule, you make a schedule inside the CTF object. This is the "more correct" way to do it, and since it would then be calling a member function of CTF you won't need the CTF:: namespace.
#7
The first thing I said was....
"This works perfectly"
Had the second one worked as well as the first, we wouldn't be discussing this
04/03/2004 (12:32 pm)
Casey did you read my post????The first thing I said was....
"This works perfectly"
$CTF::endMatch = schedule(120000, 0, CTF::endMatch());
Had the second one worked as well as the first, we wouldn't be discussing this
#8
that I will need to activate CTF as a package and then use this function to capture the schedule...
is that correct?
04/03/2004 (12:36 pm)
I'm assuming to make this schedule work..$CTF::endMatch = CTF.schedule(120000, 0, "twoMinuteWarning");
that I will need to activate CTF as a package and then use this function to capture the schedule...
function CTF::twoMinuteWarning()
{
}is that correct?
#9
What is CTF? My understanding from your code is that CTF is an object. Hence functions like CTF:twoMinuteWarning() and CTF::EndMatch(). You shouldn't need to do anything different than you are doing, just change the schedule call. Call the schedule on the CTF object instead of in the "global" namespace.
In other words, do what you say above but you shouldn't need a package to do it.
04/03/2004 (12:40 pm)
Ok you're confusing my now Gonzo :)What is CTF? My understanding from your code is that CTF is an object. Hence functions like CTF:twoMinuteWarning() and CTF::EndMatch(). You shouldn't need to do anything different than you are doing, just change the schedule call. Call the schedule on the CTF object instead of in the "global" namespace.
In other words, do what you say above but you shouldn't need a package to do it.
#10
Incidentally, did you know you can stack two function schedules together? For instance...
Will call the two minute warning function at the predesignated time and then call the end game function 2 minutes later. I find that usefull for only having to cancel one schedule instead of two in case an event is involved.
Edit: I still dont understand why everything worked fine untill I added the one function mentioned in the initial post.
04/03/2004 (1:16 pm)
No, CTF is not an object. Thats just the way I have been writting code for years and it's never been a problem till now, lol. Now that you mention it, I can see where it can be a problem with torque being set up the way it is.Incidentally, did you know you can stack two function schedules together? For instance...
$CTF::endMatch = schedule(%time, 0, twoMinuteNotify) @ " " @ schedule(120000, 0, endMatch);
Will call the two minute warning function at the predesignated time and then call the end game function 2 minutes later. I find that usefull for only having to cancel one schedule instead of two in case an event is involved.
Edit: I still dont understand why everything worked fine untill I added the one function mentioned in the initial post.
#11
You're just arbitrarily inventing namespaces?
A function in the format of CTF::blah() is an object function defintion. It means "the function blah() in object CTF".
Like in C++
04/03/2004 (1:28 pm)
I honestly don't understand what you are doing lol.You're just arbitrarily inventing namespaces?
A function in the format of CTF::blah() is an object function defintion. It means "the function blah() in object CTF".
Like in C++
class foo
{
void bar();
};
void foo::bar()
{
a = b + c;
}
#12
I understand, lol. What I was saying was I never gave it much thought before. Let me explain.
Just out of habit, when dealing with scripts, I use names that make sense. Such as, to schedule a Capture The Flag match ending I would use CTF::endMatch(). Or in the case of DeathMatch, DM::endMatch(). Since it had never been a problem for me before, I had never givin it much thought when dealing with scripts. Now obviously TorquScript is a much more robust scripting language, and more versitile, and therefore more touchy. I understand the object relation, I had just never considered it a problem. Like I said, everything I have written has been just fine except for today when I inserted that new function, then it just collapsed.
Now, lets say for a minute that since CTF is not an actual object, in theory all "CTF::" type functions "should" fail. But the have not, until today that is, and even then, its still just the new function, and in this case, any that follow it in sucession. So I'm kinda baffled as to why it works until it doesn't. And what cause it to suddenly start working wrong, or right depending on how you look at it. I can even write a bad schedule, and it will work even though it shouldn't. Something very strange is happening here, that's for sure.
I guess I just need to sit down and revamp my code in this case to convention it differently.
04/03/2004 (2:07 pm)
JohnI understand, lol. What I was saying was I never gave it much thought before. Let me explain.
Just out of habit, when dealing with scripts, I use names that make sense. Such as, to schedule a Capture The Flag match ending I would use CTF::endMatch(). Or in the case of DeathMatch, DM::endMatch(). Since it had never been a problem for me before, I had never givin it much thought when dealing with scripts. Now obviously TorquScript is a much more robust scripting language, and more versitile, and therefore more touchy. I understand the object relation, I had just never considered it a problem. Like I said, everything I have written has been just fine except for today when I inserted that new function, then it just collapsed.
Now, lets say for a minute that since CTF is not an actual object, in theory all "CTF::" type functions "should" fail. But the have not, until today that is, and even then, its still just the new function, and in this case, any that follow it in sucession. So I'm kinda baffled as to why it works until it doesn't. And what cause it to suddenly start working wrong, or right depending on how you look at it. I can even write a bad schedule, and it will work even though it shouldn't. Something very strange is happening here, that's for sure.
I guess I just need to sit down and revamp my code in this case to convention it differently.
#13
It might also be attributed to the fact that TorqueScript is a "friendly" language which tries to make it easy to use. For example the fact that you don't declare variables like in most languages. You just use them, and the first time you use them it gets declared by the compiler. Its possible something similiar was happening. You never made a CTF object but maybe TorqueScript was trying to "help" you and making one of its own. *shrug*.
04/03/2004 (2:16 pm)
CTF might indeed be an object in the codebase you are working with. That might explain the fluky behaviour.It might also be attributed to the fact that TorqueScript is a "friendly" language which tries to make it easy to use. For example the fact that you don't declare variables like in most languages. You just use them, and the first time you use them it gets declared by the compiler. Its possible something similiar was happening. You never made a CTF object but maybe TorqueScript was trying to "help" you and making one of its own. *shrug*.
#14
04/03/2004 (2:48 pm)
I guess the best way to solve this problem is to do the following...// Just before the map load put in
//
if(isObject($Game){$Game.delete();}
//
//
//
// At the end of every map load add in...
//
$Game = new ScriptObject($Server::MissionType){};
//
//
//
// Assuming the Mission type is CTF then all
// functions that I have written so far would work
// fine using...
//
$Game.blah(); or $Game.schedule(1000, "blah");
//
//
// to call them instead of setting them off directly.
//
#15
04/03/2004 (3:45 pm)
Theorticly looks fine. I have no idea what a ScriptObject is but sounds good :)
#16
I tried to fill it with a datablock, and it didn't work, but I can put anything I want into it manually(in script). Since it is a datablock that can be easily tracked and modified, I'm planning to revamp my entire scoring system using it. Basically it looks like this now....
I can now set the scoring to activate off the object be it for Capture the Flag or DeathMatch, or whatever. All I need to do to affect a score now is use $Game.Team1score++ or $Game.Team2score++ to update a cap, and I could array it from the capping player with
I like it. I'm gonna use it, lol. Not even going to worry what started all this now.
:-)
04/03/2004 (9:28 pm)
It works great dude. Perfectly in fact. I cant tell you exactly what a script object is, but I can tell you what I think it is. I believe a "scriptObject" is nothing more than an empty datablock class. It has no preset parameters like "lighttime" or "projectile". It's basically a hollow shell thats ready for you to put data into. The only example of its use I can point you to is in any of your maps. It should be the second thing, right after "SimGroup(MissionGroup)" and labled "new ScriptObject(MissionInfo)"I tried to fill it with a datablock, and it didn't work, but I can put anything I want into it manually(in script). Since it is a datablock that can be easily tracked and modified, I'm planning to revamp my entire scoring system using it. Basically it looks like this now....
function onMissionLoaded()
{
// Called by loadMission() once the mission is finished loading.
$Game = new scriptObject($Server::MissionType)
{
Team1score = 0;
Team2score = 0;
winscore = $Match::WinMatch;
};
}I can now set the scoring to activate off the object be it for Capture the Flag or DeathMatch, or whatever. All I need to do to affect a score now is use $Game.Team1score++ or $Game.Team2score++ to update a cap, and I could array it from the capping player with
$Game.(%player.team @ "score")++
I like it. I'm gonna use it, lol. Not even going to worry what started all this now.
:-)
Torque Owner Gonzo T. Clown
and this will not...
and this will work..
and this will not...