| NWN2 Scripting. |
Simulation Training. Introduction Home First Program Seeing Results Variables and Data Types Comments Functions Data Conversion Random Numbers Concatenation Arithmetic Operators Compound Assignments One More or Less Precedence Relational Operators The Open Branch The Closed Branch Logical AND Logical OR Compound Statements ELSE If Switch Case The ? Operator The for Loop The while Loop The do while Loop Introduction to Functions Passing Values Passing Multiple Values Multiple Functions Simplifying Functions TRUE/fALSE Conditions Return Values Setting Global Variables Getting Global Variables Setting Local Variables Getting Local Variables WayPoints Introduction Static Waypoint Sets Dynamic Waypoint Sets Dynamic WP Cycles Input Output |
Passing Multiple ValuesFunctions can be created so that you can apss many values to them. In the previous example you saw how to pass one value to a custom function. In this section you will see how to pass more than one value. Doing this can be a great time saver for events that you many use several times in your modules.
Creating A Function for Getting Multiple Values The following program illustrates a function that can receive three values. ta_agecheck
The above custom function (saved as ta_agecheck) has three variables declared within its pareenthesizes.
The above program will now cause the text from Message1 or Message2 (depending on the value of AgeLimit) to appear over the head of the PC.
The Calling Program The following program will call the above custom function.
The above program will call the above custom function AgeMessage( ). It does so as follows:
As you can see, the use of custom functions called from different programs can be a great time saver and result in cleaner more consistant code.
Where do we go from here? In the next section you will see how to create several custom functions which contain one or more parameters allowing the calling program to select which custom functions(s) it needs to use.
|
|