View Full Version : Functions?

Euphoric Beaver
11th Sep 2001, 05:51 AM
As you can tell I'm a newbie coder so I have a few questions concerning functions.

1) Can you make your own functions? If so how?

2) In the brackets after the function ie. (pawn) Do you have to put them in?

12th Sep 2001, 02:01 AM
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...

Euphoric Beaver
12th Sep 2001, 11:30 AM
Thanks. :)

What are the parameters for? Do you need them?

12th Sep 2001, 04:50 PM
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.

12th Sep 2001, 04:52 PM
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.