User variable

From ZDoom Wiki
Jump to: navigation, search

User variables are special variable fields that can be created in an actor's DECORATE and used for various scripting purposes. Contrarily to the args, user variables are guaranteed not to be used by any pre-existing feature, so they can be used without risk of conflict with obscure functions.

A user variable must be declared in an actor's code with a line of this form:

var int user_<name>;

Floating point and string variables are not supported at the moment. Note that the declaration ends with a semicolon. All user variable names are prefixed with "user_" to prevent any risk of conflict with future features.

It is also possible to declare arrays, using the square bracket notation to indicate a size:

var int user_<name>[<size>];

For example:

var int user_foo;
var int user_bar[42];

This creates the user_foo variable and the user_bar array with 42 elements, accessible in DECORATE expressions through user_bar[0] to user_bar[41].

See also