Basic - Writing a Function

 

A function, described in a more comparative manner, is a block of commands given to the computer in an identified manner. For example, if I told the computer to count to five, I could do it over and over every time I needed to count to five, or I could write a function that counts to five, and then simply tell the computer to do that function. This description is underappreciative of the use of functions as an escape from potential complexities and redundancies of what would be giving the same large block of commands over and over, but it's enough for a start to look at what we can do with a function. The following is the syntax in Unrealscript:

function Name( parameters )

{

//Do stuff here

}

Here we do everything from assigning values to variables, calling (or executing) other functions, and writing private (local) variables. This is the basis of how we work with Unrealscript.

 

//=============================================================================
// TestTrigger.
//=============================================================================
class TestTrigger expands Triggers;

var() Texture MySkin1, MySkin2;
var() Texture MySkin3;
var() Texture MySkin4;

function Touch( actor Blah )
{
    if ( !Pawn(Blah).bIsPlayer )
    {
    Blah.MultiSkins[0] = Texture'SoldierSkins_es.xolanimfx';
    Blah.MultiSkins[1] = MySkin2;
    Blah.MultiSkins[2] = MySkin3;
    Blah.MultiSkins[3] = MySkin4;    
    }

}