# Data types

## Overview

A data type specifies what type of data a variable can hold and must always be present at a variable’s declaration.

The script parser uses this to speed up certain operations or complain about impossible operations.

For an introduction on declaring and using variables, see Variables .

## Common types

### float

A float type variable can contain any number whether it’s an integer or a real number .

float my_var = 23;
float my_second_var = 0.5;

### vector

A vector type contains three float values, representing a vector. The engine uses this type to store map locations (vector from world origin to position), directions or angles.

When used in a normal assignment, the floats are in the order of ‘X Y Z’ indicating 3D space coordinates. To access one vector’s axis component, append _x, _y, or _z to the variable’s name. It should also be possible to use a vector’s projection on 1 axis by using the same syntax.

vector tempvector = '-128 -128 0';

// Changing the x axis value
tempvector_x = 10;

// Assigning a projected vector to another vector
vector xcomp = tempvector_x;    // xcomp = '10 0 0'


Note : Vectors do not automatically convert to strings, and can’t be set to equal floats. In these cases, the separate axis components need to be used. [1]

### entity

An entity reference. Everything in the world is an entity, so this type is used extensively. (See the info on entities in scripting basics)

entity funcmover;
funcmover = sys.getEntity("func_mover_1");

### string

A string type contains nothing more then text.

string blabla = "Put text here";

Note: A string variable can be no longer than 256 characters.

### boolean

A boolean type contains a state, true or false. It can’t be initialized at declaration, but the un-initialized variable will return zero and be interpreted as false.

boolean flag;
flag = 1;
flag = 0;

### void

Void basically means nothing .

Only to be used with functions!

## Special types

### object

Named base type of script object . Used for more advanced scripting techniques.

### [object type]

Combined entity reference and script object type reference. Will be set to null if the entity you are trying to set the reference to does not have a object of that type.

monster_base myMonster;
myMonster = sys.getEntity("monster_sam");
myMonster.wake_on_trigger();