Types

The following list describes the various code types found in the scripting language for OFP, ArmA and Arma2. It will help you to understand what sorts of values certain commands will expect. For example, if a command requires a boolean value, you know it's going to be either true or false.

Any Value

Description

Any value.


Anything

Description

Anything, including nothing.


Anything or If

Description

Anything, or If.


Array

Description

Array of items, each may be of any type.

Arrays are somewhat different from other variable types. Arrays are returned by reference.

What does this mean?

It means that the variable name you give to an array (for example myArray, or _units) references an array of values in the computer's memory.

Example

Suppose you have two numbers, _num1 and _num2.
You set _num1 to equal 5, and _num2 equal to _num1.

What do you have?
You have two completely separate variables, which store a number each, and which are both currently storing the number 5.

But what happens if you do a similar thing with a pair of arrays?

Example

_array1 = [5]
_array2 = _array1

What do you have now?
You have two variables, but each one points to the same data, in this case an array containing a single variable of type number, with the value of 5.
You can understand the difference when you try to change the two variable types around.

Taking our number type variables, suppose we set _num2 to zero.
Now we have _num2 equal to zero, but _num1 still equal to 5.

Now take the two arrays. Supposing we set _array2 to [player].

What does _array1 equal?
_array1 also equals [player].

We have modified the array that both _array1 and _array2 refer to. Exactly the same thing would happen if we set _array1 to [player] instead of _array2. Both our variables, _array1 and _array2 are two labels for the same thing.

The difference between = and set

It is important at this point to recognise the difference between two commands, set and = .

If you think about it, there are two ways we could set _array2 to [player] from its previous value of [5].

We could say

_array2 = [player]

or we could say

_array2 set [0, player].

The difference is very important. If you use = to change _array2, you will find that _array1 and _array2 now have different values completely; _array1 is still [5] but _array2 is [player].

If you use set, then both _array1 and _array2 store [player]. The reason for this lies in what you're doing with the equals. When you say _array2 = [player], you are creating an entirely new array, and assigning _array2 as the variable that points to it. _array2 is stripped away from the array that it was originally pointing to (but which _array1 still points to).

The equals command has a slighly different meaning; Here is a summary:

_a1 = [1,2,3]

The variable _a1 points to a new array which is created at the end of this statement.

_a2 = _a1

No new array is created, but the variable '_a2' now refers to the same array that _a1 refers to.

_a2 = +_a1

A new array is created which is an identical clone of the array that _a1 points to.
_a2 points to this new array.
_a1 points to the old one

_a2 = _a1 + [2]

A new array is created which is the same as array _a1 plus an extra element.

_a2 set [0, player]

The array which _a2 references is modified.
Its zero element is set to 'player'.
All variables referencing this array will return the changed array.

Because arrays are 'returned by reference' (not by value), the equality (==) operator behaves differently. Testing our two numbers, _num1 and _num2, we know that _num1 == _num2 is true when _num1 and _num2 are storing the same value. The same is NOT true of arrays.

If we had two separate arrays, and both had identical values e.g. [3,4,2].

_firstArray == _secondArray would return false, even though the values are identical. When used with arrays, the equality (==) operator compares two references and checks if they point to the same thing. From our example above, _array1 == _array2 would return true, because both _array1 and _array2 point to the same array.

Another interesting thing is what happens when we delete a variable pointing to an array. Returning to our two arrays, supposing we do:

_array2 = nil

The array is not deleted. It helps to think of _array1 and _array2 as labels, or arrows, pointing to a chunk of data (the array). Deleting _array2 removes one of the arrows, or references, pointing to the array. _array1, however, still points to the array as per usual.

(An array is normally destroyed, and its memory reclaimed, when there are no more labels pointing to it).


Boolean

Description

Boolean (true or false).


Code

Description

Functions which are marked as requiring Code accepted String in previously.

It was the prefered style to write code in curled braces, but it was not absolutely required.

This Type was introduced with ArmA.


Config

Description

Config file entry.

This Type was introduced with ArmA.


Control

Description

Control UI object.

This Type was introduced with ArmA.


Diary record

Description

Diary record.

This Type was introduced with ArmA 2.


Display

Description

Display UI object.

This Type was introduced with ArmA.


Exception Type

Description

A helper type used in try-catch constructs.

This Type was introduced with ArmA.


For Type

Description

This type handles For cycles.

Usage of this type:
for "_var" from :expr: to :expr: [step ] do {..code..};

Second usage:
for [":initPhase:",":condition:",":updatePhase:"] do {...code...};

This Type was introduced with ArmA.


Group

Description

Group.


If Type

Description

Helper type used in an if...then construct.


Location

Description

A location is an extended type of marker.

Locations:

  • Have a name, side, Position, 2D area and an orientation
  • Have a non-scaling map representation (icon and/or text, depending on class)
  • Require a class definition to define basic properties that can be changed using script commands. Classes are defined in bin\Config.bin\CfgLocationTypes
  • Can be attached to objects, with the location's relevant properties inherited from the object
  • Can use setVariable and getVariable
  • Are local in MP, their properties are not synchronized

Existing locations are set in an islands .pew file. When the island is exported to .wrp, the islandname.hpp is also produced, this contains the location names used in the .pew file. This .hpp is then incorporated into the config for the island using an #include statement. This section, when included in the island config, ensures that any locations set in the .pew file are included on the island during packing.

A terrain config can not be changed using the location script commands, but, they can be found and read. This provides a single command method of finding nearby high points, towns, etc.

This Type was introduced with ArmA.


Namespace

Description

Namespace - set of variables.

This Type was introduced with ArmA 2.


Nothing

Description

Nothing - no value.


Number

Description

Real number.


Number or Nothing

Description


Object

Description

Game object, like soldier, vehicle or building.


Object or Array

Description

Object, or Array.


Object or Group

Description

Object, or Group.

If you pass Group, leader is considered.


Object or String

Description

Object, or String.


Orientation

Description

For future implementation.

This Type was introduced with ArmA.


Script

Description

Script handle, used to identify scripts in script operations.

Script is usually started using spawn or execVm or execVM. Scripts use the same syntax as Functions - SQF, but there are a few specialized commands which can be used only in scripts, like sleep or waitUntil.

This Type was introduced with ArmA.


Side

Description

Name of side (see west, east, civilian, resistance).


String

Description

ASCII string.


String or Array

Description

String, or Array.


String or Code

Description

String, or Code.


Structured Text

Description

Rich text formating, is able to include pictures.

It can be created using XML like syntax, as seen in parseText.

This Type was introduced with ArmA.


Switch Type

Description

A helper type used in switch constructs.

This Type was introduced with ArmA.


Target

Description

For future implementation.

This Type was introduced with ArmA.


Task

Description

Task.

This Type was introduced with ArmA 2.


Text or String

Description

Text, or String.


Transformation

Description

4x3 matrix (orientation + offset). This is a reserved keyword for future implementations.

This Type was introduced with ArmA.


Vector

Description

For future implementation.

This Type was introduced with ArmA.


While Type

Description

Helper type used in while...do constructs.

This Type was introduced with ArmA.


With Type

Description

Helper type used in while...do constructs.

This Type was introduced with ArmA 2.

Advertisement