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

Active 7 months ago
Joined Jan 2016
Points:
950

User statistics:

  • Modifications: 0
  • Forum topics: 32
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 155
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.

Active 7 months ago
Joined Jan 2016
Points:
950

User statistics:

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

hahah yes that is true 

Active 6 years ago
Joined Jan 2017
Points:
705

User statistics:

  • Modifications: 0
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
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%?

Active 6 years ago
Joined Jan 2017
Points:
705

User statistics:

  • Modifications: 0
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
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%?

Active 5 years ago
Joined May 2013
Points:
785

User statistics:

  • Modifications: 4
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 16
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.

Active 6 years ago
Joined Jan 2017
Points:
705

User statistics:

  • Modifications: 0
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
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