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

Getting Global Variables

In the previous session you saw hwo to assign values to NWN2 GLobal Variables. In this session you will see how to get the values from previously declared and defined NWN2 Global Variables.


NWN2 Global Variables General Form

To get a value from a previously ldeclared and assigned NWN2 Global Variable:

GetGLobalType("Identifier");

Where:

  • Type is one of three allowed data types of: Int, Float, or String.
  • Identifier is the token used to identify the variable, this may be any string.


NWN2 Global Variable Examples:

The following program illustrates examples of getting values from previously declared and assigned NWN2 Global Vaiables with the three different allos NWN2 Global Variable data types.

void main()

 {

  int intValue;

  float fitValue;

  string stgValue;

   intValue=GetGlobalInt("MyInt");

   fltValue=GetGlobalFloat("MyFloat");

   stgValue=GetGlobalString("MyString");

 }

Explanation:

          For the GetGlobalInt()

Term Meaning
GetGlobalInt Keyword for getting a value from a NWN2 Global Variable of data type Integer (int).
"MyInt: The variable identifier. Note that it is of data type string and must be enclosed in quotes.
intValue The variable that will receive the previously assigned value. Note that his must be of data type int.

      For the GetGlobalFloat()

Term Meaning
GetGlobalFloat Keyword for getting a value from a NWN2 Global Variable of data type Float (float).
"MyFloat" The variable identifier. Note that it is of data type string and must be enclosed in quotes.
fltValue The variable that will receive the previously assinged value. Note that this must be of data type float.

      For the GetGlobalString()

Term Meaning
GetGlobalString Keyword for getting a value from a NWN2 Global Variable of data type String (string.)
"MyString" The variable identiifer. Note that it is of data type string and must be enclosed in quotes.
stgValue The variable that will receive the previously assigned value. Note that this must e a data type string.


Where do we go from here?

The next section introduces NWN2 Local Variables.

Nwn2Scripting provides material for training only. We do not warrant the correctness of its contents. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 2008 by Adamson House, Ltd. All Rights Reserved.

Questions or Comments: EMail Webmaster

Donations are to Adamson House, Ltd who maintains this site.
All donations go the the improvement of this site.