Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Random number - lower limit above 0?

A topic by ChristopherMerriner created Jun 25, 2020 Views: 87 Replies: 5
Viewing posts 1 to 2

Hi

Is there a built-in way of getting a random number with a lower limit above 0?  I use a workaround at the moment, eg. if I want 10 as the lower limit then I ask for a random number, check it and if it is less than 10, ask for another random number. Is that the only way, or am I overlooking something obvious?

Submitted

I'm not sure I understand, but something like this?

integers {
   int_rnd : integer "0" ;
}
on_command {
   : match "test -"  {
      : store_random var = "int_rnd";
      : add var = "int_rnd" value = "10" ;
   }
}
Host

Auraes provides the only solution that will work in 8-bit compatibility mode.

(1 edit)

Thanks - that works, but I was wondering if there was a command that would do: 'give me a random number between [lower end] and [upper end]' without having to get a number between 0 and 999 and then further manipulate the output. In 8-bit or otherwise. But I guess not.

In any case, doesn't really matter - there are easy ways to get what I need.

Host

I'm not quite ready to document advanced scripting forms yet, but in the beta version this will work:

: print {("A random number between 25 and 30 will be printed next : " + random { min="25" max="30"} )}

Yes, that is it exactly. Good to know it's there. Thanks!