Data types

From modwiki

Jump to: navigation, search

Contents

Overview

A data type specifies what type of data a variable can hold and must allways 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 allso 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 seperate axis components need to be used. [1]

entity

An entity type contains a reference to an entity. 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";

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 basicly means nothing.

Only to be used with functions!

Special types

These types are rarely used in scripts and are here for reference purposes only.

Some are suposed to work but need some research for their exact usage.

scriptEvent

Used to declare a script event as available from the game code. Should only be used in the events declaration script, not in other code.

Image:D3square_25.png Doom 3:
The declaration script is doom_events.script

Image:Q4square_25.png Quake 4: 
The declaration script is events.script

(Might not be a true datatype but something function-like. Needs some research on where to place in wiki)

user_defined

for a user defined type which inherits the object type. Replace the "user_defined" with the name you wish for your defined type. Typically, the type is declared with the keyword "type", but I'm not sure if this feature is fully implemented in script.

object

Needs more research. Can be Q4 specific.

(The example code located here is moved to Scripting basics#Objects

Personal tools
Main