# Using a random value as a parameter

**URL:** <https://narrat.discourse.group/t/using-a-random-value-as-a-parameter/373>\
**Category:** Help\
**Created:** [3 May 2025 03:33 UTC](https://narrat.discourse.group/t/using-a-random-value-as-a-parameter/373 "2025-05-03T03:33:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rex\_Fox](https://avatars.discourse-cdn.com/v4/letter/r/53a042/32.png) [@Rex\_Fox](https://narrat.discourse.group/u/Rex_Fox)\
**Post date:** [3 May 2025 03:33 UTC](https://narrat.discourse.group/t/using-a-random-value-as-a-parameter/373/1 "2025-05-03T03:33:59Z")

</div>

Hello everyone, I hope you all are well.

I ask for help here, how can I save a value that I obtained in a random (for example; 1 to 20), to use as a counter/var later?

```auto
Example:
main:
  random 1 20
  set data.rng random (?)
  jump result

result:
  if (>= $stats.rng 11):
    add_xp str rng (? Equal to the value obtained in RNG)

```

How can I make this happen? I know that if I assign a fixed value, I can do it, but I wanted to use the value generated by random and I don’t know how to do it.

* * *

Like the noob syndrome, for some reason after I posted this here, I remembered the $ and (integer/var) rule. Since I know there are always questions on the forum, instead of deleting the question, I’ll leave how to do it in case someone comes here in the future. The command is;

set data.var (random x y)

replace the X and Y values ​​with the Minimum (X) and the Maximum (Y). Then just call the value with $ to use. In the case for what I need, which is for this grind, it is;

add\_xp skillid $data.var

So in my own example, it works like this;

```auto
Example:
main:
  set data.var (random 1 20)
  jump result

result:
  if (>= $stats.rng 11):
    "Wow! Now I have +%{$data.var} points!"
    add_xp skillid $data.var

```

Sorry for the trouble. +You cannot use 0, it has to be at least 1. If you use 0, it may give an error at some point, if the random value becomes 0 and the system needs to add it.
