Assignments


An assignment simply stores a value in a variable and has the form:

<variable> = <expression>;

An expression can be a simple value but can also be more complicated, so, rather than assigning a value to a variable, one can also add a value to the current value of the variable using +=, for example:

a = 100;   // Assigning a simple value
b = 200;
c = 300;
a += b;    // Assigning with operation
a = b + c; // Assigning with expression

NOTE: The GameMaker Language will also accept ":=" for assignments, although this is not typically the most common way to do it:

<variable> := <expression>;


Similarly, you can subtract using -=, multiply using *=, divide using /=, or use bitwise operators using |=, &=, or ^=. You can also add or subtract one from a value using ++, --. For further information see the section on Expressions.

Note that you cannot do the following (or any variation):

var a, b, c;
a = b = c = 4;

And instead it should be done as:

a = 4;
b = 4;
c = 4;