Scripting processes and events.
by Chris "Dark" Evans · in Torque Game Engine · 12/17/2001 (10:54 am) · 2 replies
You guys really should have a scripts-only forum.
These are kind of dumb questions, but I need to know for sure.
I'm not sure exactly how to write this in terms anyone can understand, so I'll write it in code.
If I call startTest(), it will call test1() first, after it's finished, and Only(?) after it's finished it will call test2(), right? It will not ever go to test2() unless test1() is finished, right?
After test1 finishes, test2 gets called. Test2 has a never ending loop. lets pretend that this loop doesn't crash the game like it obviously will :). Since test2 loops forever, test3 should never get called, right?
In my second example, the very last thing to happen should be test2, right? It will only process test 2 after the entire tree behind it is complete, right?
In C++, or VB, and other languages everything is processed in order, through the entire sequence. Is this how it is with torque scripts?
A real-world example would be:
Ok, not so real-world :) The complexity of the loops don't matter, what matter is the length. startExample callse buildArray, then processArray. buildArray has a pretty big loop in it, so it could take some time to complete. Does that mean it skips ahead and calls processArray? Or does it wait until buildArray is finished?
I'm sorry these questions are so stupid. I'm getting some really strange problems in my inventory code (Gui based, like Diablo 2 and other RPG games). It uses a lot of for statements to get the position of items, and which inventory control they're under. I want to make sure that it isn't skipping things and isn't processing them. These seem like random crashes, which I can't figure out.
Dark
These are kind of dumb questions, but I need to know for sure.
I'm not sure exactly how to write this in terms anyone can understand, so I'll write it in code.
function startTest()
{
test1();
test2();
test3();
}
function test1()
{
for(%x = 0; %x < 100; %x++)
error("TEST: " SPC %x);
}
function test2()
{
while(true)
{
error("Loop forever");
}
}
function test3()
{
error("blah");
}If I call startTest(), it will call test1() first, after it's finished, and Only(?) after it's finished it will call test2(), right? It will not ever go to test2() unless test1() is finished, right?
After test1 finishes, test2 gets called. Test2 has a never ending loop. lets pretend that this loop doesn't crash the game like it obviously will :). Since test2 loops forever, test3 should never get called, right?
function startTest2(){
error("startTest");
test1();
test2();
}
function test1(){
error("test1");
test1a();
test1b();
}
function test1a(){
error("test1a");
test1aa();
}
function test1aa(){
error("test1aa");
for(%x = 0; %x <1000; %x++)
error("TEST!!!!!! " @ %x);
}
function test1b(){
error("test1b");
// do nothing
}
function test2() {
error("test2");
// this should be the very last process.
}In my second example, the very last thing to happen should be test2, right? It will only process test 2 after the entire tree behind it is complete, right?
In C++, or VB, and other languages everything is processed in order, through the entire sequence. Is this how it is with torque scripts?
A real-world example would be:
function startExample()
{
buildAray();
processArray();
}
function buildArray()
{
for(%x = 0; %x < 10000; %x++)
$Array[%x * 2] = %x;
}
function processArray()
{
for(%x = 0; %x < (10000 * 2); %x *= 2)
error($Array[%x]);
}Ok, not so real-world :) The complexity of the loops don't matter, what matter is the length. startExample callse buildArray, then processArray. buildArray has a pretty big loop in it, so it could take some time to complete. Does that mean it skips ahead and calls processArray? Or does it wait until buildArray is finished?
I'm sorry these questions are so stupid. I'm getting some really strange problems in my inventory code (Gui based, like Diablo 2 and other RPG games). It uses a lot of for statements to get the position of items, and which inventory control they're under. I want to make sure that it isn't skipping things and isn't processing them. These seem like random crashes, which I can't figure out.
Dark
#2
Thanks :)
Dark
12/17/2001 (12:02 pm)
I assumed so, but when debugging everything is a potential cause.Thanks :)
Dark
Torque Owner Josh Goldshlag
Having it work the other way would make things very difficult... :-)
Josh