Started by
RedRaspy156
on
Mon, 05/23/2022 - 22:10
Topic category: Troubleshooting, bugs, and solutions
I've been having difficulty trying to solve why sometimes this else if calls a separate procedure twice.
Could someone possibly find a way to fix this or change the way it is setup?
Here is an image:
Edited by RedRaspy156 on Mon, 05/23/2022 - 22:11
Hey, I can't view the image. It's probably because you copy-pasted it, sadly, it doesn't save that way. Could you upload it to imgur or ibb?
Oh sorry about that
Hopefully this works:
https://imgur.com/berhl6L
The "Random [0, 1]" blocks are independent of one another, meaning they will all run in succession. You have to store the result of one "Random [0, 1]" block to a local variable before you use the random number, then assign ranges to each if-else statement. For example, if you have 4 possible outputs, you can have the else-if conditions as follows:
If (0 >= [local var] < 0.25)
output 1
else if (0.25 >= [local var] < 0.5)
output 2
else if (0.5 >= [local var] < 0.75)
output 3
else
output 4
These ranges can all be equal, as shown in the above example, or each range can be different:
If (0 >= [local var] < 0.05)
output 1
else if (0.05 >= [local var] < 0.4)
output 2
else if (0.4 >= [local var] < 0.88)
output 3
else if (0.88 >= [local var] < 0.94)
output 4
else
output 5
Make sure that you set a local variable to a random number prior to using it - do not use the random block for the examples I have given.