Randomizing

Started by Benoniusthecat on

Topic category: Help with modding (Java Edition)

Last seen on 07:43, 11. Feb 2023
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Randomizing
Sat, 09/21/2019 - 17:24 (edited)

I was thinking about making a kind of radio receiver thing that when used, will give you a random message with help on the mod, but how could I randomize it? If you have a solution, let me know! (NOTE: I am not wanting this to be a block)

Edited by Benoniusthecat on Sat, 09/21/2019 - 17:24
Last seen on 19:55, 7. Jan 2021
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Try creating a local number…
Sat, 09/21/2019 - 09:30

Try creating a local number variable and in a procedure set it to random [0,1]
Then make an if statement to test if it is 0 or 1 and put the messages in those.
This might also help.
https://www.youtube.com/watch?v=GE0kHWQLy4c&list=PLAeL-oIFIEngE6jRgFYeF…

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
https://www.youtube.com…
Sat, 09/21/2019 - 12:03

https://www.youtube.com/watch?v=SBtTsNYiHzw

If you don't want a 50/50 randomiser but want to have, say 5 messages of which 1 has to appear at random: 1/8 = 0.125.PROCEDURE:


Set random_local_variable to random[0,1]

if random_local_variable < 0.125

do message 1

else if random_local_variable < 0.125 * 2

do message 2

else if random_local_variable < 0.125 * 3

do message 3

else if random_local_variable < 0.125 * 4

do message 4

else

do message 5

 

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
EDIT: the 0.125 was meant…
Sat, 09/21/2019 - 12:04

EDIT: the 0.125 was meant for 8 results. change that number to 1/5 = 0.2

I suggest you check our…
Sat, 09/21/2019 - 13:00

I suggest you check our tutorials collection playlist on our YouTube channel which contains many examples and tutorials that can help you get started with MCreator: https://www.youtube.com/playlist?list=PLAeL-oIFIEngE6jRgFYeFMfuj8WQsO3Ei

Last seen on 07:43, 11. Feb 2023
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks! This worked after a…
Sat, 09/21/2019 - 19:16

Thanks! This worked after a few tries and I really like the result!