General function knowledge

(Just re-read the title and chuckled.)

Is there reading on setting custom functions?

I know that if you have a regular function like OnTriggerEnter (other: Collider){} you can fill it with things that are not the trigger by specifying “other.” before the script. But what about custom ones?

The set up is familiar as it is normally constructed, but I’ve seen some function routines start off with some weird and complex stuff and I just don’t get it. If it is a custom function, what goes in these blank parts?

function Something(______ : ________){

}

the rules of that have eluded me, and I’m just searching for some reading on it, but without knowing what those two blank variables are, I have no idea what to search for. Thanks for any links or info.

I’d first like to echo Benproductions’ comment regarding doing some reading on programming in general.

To answer you question, however, so that it might be closed out with an answer others may also find to be useful, the parts that you’re referring to are called the variable name and type name, in that order.

UnityScript:

function DoSomethingAwesome(variableName : TypeName)
{
    // do amazing things
}

C#:

void TheMostAwesomeMethod(TypeName variableName)
{
    // hack something here
}

In the above examples I’ve tried to make it as plain to see as possible. You can use the variable, ‘variableName’ within the scope of the function/method that defines it. This allows you to pass in values from other functions/methods. A function, by definition, returns a value that is based on another value, although in the Computer Sciency realms we accept that functions do not require variables, and do not necessarily need to return anything useful. UnityScript shields the user from the majority of that pedantry, however, while in C# you must still declare the return type even if nothing is sent back to the calling method (hence, void).

As noted below by Benproductions, another point that applies to Unity; languages typically have their own idiosyncrasies when it comes to how they define scope. Unityscript, for instance defaults the methods to being public, that is accessible outside of the defining class. C#, on the other hand defaults them to being private, or not accessible outside of the defining class. In either case, use of the access modifiers ‘public’ and ‘private’ will override the default behaviors.

Also, for more more in-depth, check out vexe’s answer, here.

Now. Go find some useful books on your language of choice!