 This page is not fully translated, yet. Please help completing the translation.
(remove this paragraph once the translation is finished)

# Writing expressions

GDevelop supports expressions! Expressions are dynamic values that can be used in event parameters. For example to set an object position, you can use a fixed number as `75` or you can use an expression such as `AnotherObject.X() - Variable(position_offset)`.

There are two types of expressions:

• Numerics

Numerics can be used in event parameters. They receive a numeric value such as object position, z-order, variable number, etc.

• Strings

Strings can be used in parameters that receive a text/string value. You can use this expression to read the content of a text object string, its color, the text of another variable, etc.

## Numeric expressions

As stated above, Numeric expressions can be used in numeric parameters.

### Random values

`Random(max)` - Returns an integer between `0` and the `max` value that is defined. The “range” is [0, max].

Examples using the Random() Expression:

`Random(3)  // The 3 possible integer values are 0, 1,  2,  and 3`

`RandomInRange(min, max)` - Returns an integer between `min` and `max`. The “range” is [min, max].

Examples using the RandomInRange() Expression:

```RandomInRange(-1, 2) // The 4 possible values are are  -1, 0, 1,  and 2

// Note that "RandomInRange(min, max)" is equivalent to "min + Random(max - min)":
-1 + Random(2 - -1) // This gives the same results as above```

`RandomFloat(max)` - Returns a float between `0` and `max`. The range is `[0, max)`. Note that `max` is not included in the range. It's important to also note that the possible results are infinite. This is because there are infinite real numbers between any two different values.

Examples using the RandomFloat(max) Expression:

`RandomFloat(2.5) //SOME of the many possible values are 0, 1.467798, 2.000587, and 2.499999`

`RandomFloatInRange(min, max)` - Returns a float between `min` and `max`. The range is `[min, max]`. Note that `max` is not included in the range. It's important to also note that the possible results are infinite as there are infinite real numbers between any two different values.

Examples using the RandomFloatInRange() Expression:

`RandomFloatInRange(-1.5, 2) //SOME of the many possible values are -1.5, -0.598156, 1.000874 and 1.99999`

`RandomWithStep(min, max, step)` - Returns a number between `min` and `max` in steps. The range is `[min, min + N*step]` with `min + N*step ≤ max < min + (N+1)*step`. It means it can return any of the stepped values that are less than or equal than `max`.

Examples using the RandomWithStep(min, max, step) Expression:

`RandomWithStep(1, 3, 0.6) // The generated numbers are ``1``, ``1.6``, ``2.2`` and ``2.8```