# Orx Learning

### Site Tools

en:tutorials:config_stepped_random_values

# Getting Stepped Random Values from Config

You would be familiar with retrieving a random value from the config by writing:

```[Values]
Randoms = 0 ~ 1999```

And in code:

```if (orxConfig_PushSection("Values")){
orxU32 value = orxConfig_GetU32("Randoms");
orxLOG ("Value: %d", value);

orxConfig_PopSection();
}```

This will give you a random number, eg:

` Value: 1675`

## Stepped Integers

You can also define stepped random values using the following format:

```[Values]
Angles = 0 ~ 45 ~ 360```

`orxU32 value = orxConfig_GetU32("Angles");`

` Value: 270`

In the example above, `0 ~ 45 ~ 360` would mean to define a range of values between 0 and 360, 45 steps apart.

Other examples would be:

``` 0 ~ 1 ~ 10  (standard number range of 1 to 10, steps of 1)
0 ~ 1 ~ 1   (like a binary switch 0 or 1, same as 0 ~ 1)
1 ~ 5 ~ 100 (1 to 100 in steps of 5)
0 ~ 2 ~ 10  (an even number between 0 to 10)```

## Code examples

You can also do this from code using any of the following functions:

1. `orxMath_GetSteppedRandomFloat`
2. `orxMath_GetSteppedRandomU32`
3. `orxMath_GetSteppedRandomS32`
4. `orxMath_GetSteppedRandomU64`
5. `orxMath_GetSteppedRandomS64`

An example:

```orxFLOAT val = orxMath_GetSteppedRandomFloat(1, 100, 2.1);
orxLOG ("Value: %f", val);```

` 11.50000`

So the above would be floats 1 to 100 in steps of 2.1. You can get more details about those functions here: http://orx-project.org/orx/doc/html/group__orx_math.html

## Stepped Vectors

A little tricker, but the same nonetheless:

```[Values]
MyRandomVector = (1, 3, 5) ~ (0, 0.1) ~ (2, 4, 6)```

• X will be unconstrained between 1 and 2 (step = 0)
• Y will be between 3 and 4 with a step of 0.1 and;
• Z will be unconstrained between 5 and 6 (no Z component, which means: Z = 0)

## More details

You can get more detail and examples in the Creation Template here or in your local repo of Orx. 