FANDOM


When the CoD engine starts reading code, it will read it similar to a human, from the top to bottom.

1.  programFlow()     // first line game reads
2.  {                 // second line game will read
3.                    // third line
4.  }                 // last line


When creating functions, you want to place code in the order of what you want executed first to last. When you thread functions, you can use "self" or "self thread" to call them. The difference between the two is that "self" will wait for the function you called to terminate before it continues with the code, whereas "self thread" will call the function and continue to run the rest of the code even if the function called is still running.


programFlow()
{
    self thread exampleCode();
    //the game will print "Function 1 Completed!" right after "exampleCode" is called, without waiting for it to end
    self IPrintLnBold( "Function 1 Completed!" );

    self sampleCode();
    //the game will wait until the function "sampleCode" is done before printing "Function 2 Completed!"
    self IPrintLnBold( "Function 2 Completed!" );
}

exampleCode()
{
    wait ( 1.0 ); //wait one second
}

sampleCode()
{
    wait ( 1.0 ); //wait one second
}

In the above exaple, the game will execute "exampleCode" and instantaneously print "Function 1 Completed!" without waiting the one second within the function "exampleCode", and then it will execute the function "sampleCode" which doesn't contain the "thread" command, but it will wait until the function is done, which in this case is waiting one second before printing "Function 2 Completed!".