How to compare number properties?

How can I make a block to compare 4 number properties and determine the largest one?

2 Likes

Use blocks
multiple of them. EX if a>b then broadcast A else broadcast B. and so on.

You’ll need to use block code, in which you can use the “if/else” conditional block to check if a number is greater than another number. If you have 4 numbers, you can create 16 unique 2-number combinations, so add 16 if/else blocks, each comparing 2 numbers. At the beginning of the script, set a variable called “greatest number” to 0. Then, inside the “if” section of each “if/else” block (make sure you do add an “else” section), set a variable called “greater of pair” to the first property (the greater one). In the “else” section, set the variable to the second property. add another if/else block that checks if the “greater of pair” variable is greater than the “greatest number” variable. If it is not, do nothing and continue the script. If it is, set the “greatest number” variable to the “greater of pair” variable. Make sure this is run after each of the 16 if/else blocks.

And you’re done! At the end of the script, the “greatest number” variable will be the greatest of your four numbers.

Let me know if you need more details or have any questions or concerns!
Hope this helped!

5 Likes