1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.

Functions?

Discussion in 'Programming' started by Euphoric Beaver, Sep 11, 2001.

  1. Euphoric Beaver

    Euphoric Beaver impeccably groomed

    Joined:
    Apr 19, 2001
    Messages:
    3,158
    Likes Received:
    0
    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?
     
  2. ca

    ca CHiMERiC Grandmaster

    Joined:
    Oct 11, 1999
    Messages:
    84
    Likes Received:
    0
    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...
     
  3. Euphoric Beaver

    Euphoric Beaver impeccably groomed

    Joined:
    Apr 19, 2001
    Messages:
    3,158
    Likes Received:
    0
    Thanks. :)

    What are the parameters for? Do you need them?
     
  4. ca

    ca CHiMERiC Grandmaster

    Joined:
    Oct 11, 1999
    Messages:
    84
    Likes Received:
    0
    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.
     
  5. ca

    ca CHiMERiC Grandmaster

    Joined:
    Oct 11, 1999
    Messages:
    84
    Likes Received:
    0
    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.
     

Share This Page