Announcement

Collapse
No announcement yet.

Please explain function().

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Please explain function().

    I'm not going to ask a whole lot. "please write my entire mod I have a great idea!" I know you all have lives.

    Can someone explain what the () stuff is after the function name

    such as,

    function MyFunction (out byte Name, other pawn)


    I don't know if that one makes sense but nothing makes sense to me. What's that stuff in the ()?

    #2
    the stuff in the brackets is already telling you what the stuff in the brackets is :P

    Comment


      #3
      This is basic programming concept so what you learn here will apply to almost any language you can program in.

      The things inside the brackets are parameters. When you run a function you pass data to it, using the parameters to allow the function to carry out it's function. here's an example:

      function WriteStuff(string Text)
      {
      log(Text);
      }

      Somewhere else in the code....

      WriteStuff("HelloWorld");

      This means that when you call the WriteStuff function, the data that you put in the brackets (in this case "HelloWorld") will be sent to the WriteStuff function and put in the variable Text. Then it can be used by the function. This way you can use the same function on any other data as long as it's of the type specified in the function which is a string in this case.

      There are a some keywords that change how the parameter works slightly. Eg:

      Function DoStuff(optional int Num, out byte Value)
      {
      ...some stuff
      }

      The optional means that the function will work if you don't put anything in that parameter but depending on what the function does you might want to. The out means that the parameter sort of works the opposite way round. The function will pass data out of the function and into wherever you called it from. So to call this function:

      DoStuff( , Val);
      Since the first parameter is optional it can be left out so I have just put a comma to go to the next one. The variable Val will now be set to whatever Value is calculated as in the function DoStuff.

      If you're still not quite sure I suggest you find some general programming tutorials since this stuff is useful whatever language you do.

      Comment


        #4
        No you explained it like a pro.

        Thanks a ton.

        Comment


          #5
          To start out making mods to a game such as UT2K4 I would strongly suggest learning some basic programming skills. If you're going to do anything with UT you will need to know about inheritance at least.. you cant really just go altering the original source code, you need to inherit. Parameters and variables also need to be understood. With the basics covered you should then be at least able to do some basic cutting and pasting or alter some defaultproperties.

          Here's a page full of tutorial links for the C++ language
          http://www.freeprogrammingresources.com/cpptutor.html

          For a lot of great tutorials on Java go to
          http://java.sun.com

          And of course theres the Unreal Wiki which I believe has the basics of programming covered too?
          http://wiki.beyondunreal.com

          If you have the DVD version of UT2K4 you should have the bonus disk with tutorials on it, in the section for unreal scripting im sure they cover stuff like parameter passing etc.

          Comment

          Working...
          X