void main()

This function declaration is necessary for all script with the exception of conversation scripts, and #include files. All statements to be exectuted should fall within this functions code block. Any custom functions used within the main() code block should be declared before it (above the void main() line) by declaring a function or using a function prototype.

// declaration of a function
int getAge(object oPC) 
{
     // ...
     return 0;
}

// function prototype (this function body appears after
// void main()
string getName(object oPC);
 
// main program execution
void main()
{
     // main code block
     PrintString(getName(GetFirstPC()));
     PrintInteger(getAge(GetFirstPC()));
}

// our "getName" function body appears below (after 
// void main() so it was prototyped above)
string getName(object oPC)
{
     return "";
}




 author: Ryan Hunt, editor: Charles Feduke
 Send comments on this topic.