random number

random number



Kode wheel segment Math/Random
Style Math
Modifiers  to / as integer
Primarily WHEN/DO DO
Pre-made brains that use it Unknown

Math > Random > random number


This tile is a Math tile. It is used to create a random number based on game time. By default it will pick a number between 0 and 1, but you can modify that by selecting a range. Because it is based on game time you cannot set a truly random number using timers, or on the first frame of your game, as the number selected, although random, will be the same every time you play (because the point at which the random number is generated is at the same game time). To get a different number you need a random input, such as a button press to generate your number.

If you build you game with a press button to start option on your first screen, the game time at which the rest of your game plays will be different each time, so now any random number generated will be different each time.

Example Code


WHEN [once] DO [numvar:my random number][=][random number][1][to][5][as integer]


to: Paired with a number each side to establish a number range. Without a further modifier it will create a number up to 4 decimal places (such as 1.8752). See kode example.

as integer: An integer is a number with no decimal fractions, such as 3, 7, 86. So if you want to choose a random whole number between two numbers you need to specify [as integer]. In the above example you will get either 1,2,3,4 or 5 – without this tile you would get results such as 1.5634, 2.7002.

Other Uses


Comments are closed.

Website Powered by WordPress.com.

Up ↑

%d bloggers like this: