Functions?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

ca

CHiMERiC Grandmaster
Oct 11, 1999
84
0
0
www.unrealscript.com
Uhm, a new function can be declared very simply:

function <return type> FunctionName(<parameter type> ParameterName, ...)
{
// function code goes here
}

Not all functions need to have a return type, and functions don't always have paremeters either. If you do specify a return type make sure to exit your function with the return keyword:

return None; - or -
return <return type>

An example function:

function bool IsAFunction()
{
return true;
}

Does that help at all? Just look at all of UTs functions and I think you can probably figure it out. Nothing special to make new functions...
 

ca

CHiMERiC Grandmaster
Oct 11, 1999
84
0
0
www.unrealscript.com
Parameters are variables passed to a function, and it depends on the function on whether or not you need them. Say you have a function that replaces a player's weapon, you'll need to pass the player to the function so it knows what player to work with.

Or like the log function - it needs a string to send to the log file, and thus it takes a string variable.
 

ca

CHiMERiC Grandmaster
Oct 11, 1999
84
0
0
www.unrealscript.com
Just keep in mind that there are no global variables in Unrealscript, only class (var) and function (local) variables. So when you need to work with a piece of data you are responsible for passing the data along to functions as necessary, via the parameters.