Guide on how to use probability for an effect after a food is eaten (1.12.2)

Started by DerexXD on

Topic category: User side tutorials

Last seen on 19:30, 8. Feb 2023
Joined Jan 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Guide on how to use probability for an effect after a food is eaten (1.12.2)
Thu, 08/08/2019 - 17:10 (edited)

You want to utilize the random block and create a NUMBER local variable (Right side) 

I called mine random

Then SET the variable to Random 0,1 * 100

The Set block can be found in Custom Variables tab. The number is found in the math tab so is the multiplication sign 

Drag a if, do into the area from the logic and loops tab

Next go to logic operators and take out the second one, with the symbols of comparison. Get the GET block from the custom variables tab. Set the symbol to less than and put your variable on the left side. The right side should be the percentage you want it to fall in. 

In the "DO" part put in execute command (then put in the effect command)

 

Example

 

Edited by DerexXD on Thu, 08/08/2019 - 17:10
You don't need to multiply…
Fri, 08/09/2019 - 09:37

You don't need to multiply this by 100, jus check if random is smaller than 0.4, but your approach is fine too.

Last seen on 19:30, 8. Feb 2023
Joined Jan 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
hahah yes that is true 
Fri, 08/09/2019 - 13:38

hahah yes that is true 

Last seen on 17:47, 11. Nov 2019
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
quick question. in the…
Fri, 11/01/2019 - 20:14

quick question. in the method presented is the chance to get the slowness effect 40%?

Last seen on 17:47, 11. Nov 2019
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if so would changing it to…
Fri, 11/01/2019 - 20:16

if so would changing it to 10 make it 10% and or 1 make it 1%?

Last seen on 04:55, 23. Dec 2019
Joined May 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Think about it this way…
Fri, 11/01/2019 - 21:52

Think about it this way. Random(0,1) generates a random decimal double between 0 and 1.
Because you multiplied this value by 100, it effectively generates a random decimal double between 0 and 100.

If you wanted to optimize this further, you don't have to multiply it by 100 or even not save it as a variable.

Last seen on 17:47, 11. Nov 2019
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ahh i see makes sense make…
Fri, 11/01/2019 - 22:38

ahh i see makes sense make sense lol thanks fo the swift reply