Tutorial to generate random number

Started by Ergosphere on

Topic category: User side tutorials

Active 8 months ago
Joined Sep 2021
Points:
545

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 6
Tutorial to generate random number

You can use the code below the generate a random number. The top function is for when your minimum is 1. The bottom is for any other scenario.

For each function interchange 15 for your maximum number and change 5 for your minmum in the bottom one.

In code form the formula looks like this: 

(Math.random() * (maximum - minimum + 1)) + minimum

Rand

Active 3 years ago
Joined Mar 2022
Points:
459

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 12
Sorry but, Where should i…
Thu, 03/17/2022 - 23:50

Sorry but, Where should i put that in the structure of the code-blocks? It doesn't matter or it does?

Active 3 years ago
Joined Mar 2022
Points:
459

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 12
Sorry but, Where should i…
Thu, 03/17/2022 - 23:56

Sorry but, Where should i put that in the structure of the code-blocks? It doesn't matter or it does?