Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Min/Max over variables, and Lookup

7 years ago

Haven't seen anything on this in the articles, is there a simple way of using min/max over multiple variables? Also, do we have an equivalent to Excel's lookup (vlookup in this case)?

The mechanic in this question in factional loyalty, I want to award bonuses based on which faction has the most loyalty points. Again, is there any way to avoid comparing every faction to a check variable (and storing the highest faction value and name in two separate variables) in descending order? (The first part requires a max/min, the second would benefit from a lookup

Min/Max over variables, and Lookup

7 years ago
I don't believe there is anything built in. You could write a massive section of Javascript to do this, though.

Min/Max over variables, and Lookup

7 years ago

My own skills are more in the logic department and not yet in the coding side >_<

Thanks for the heads up though

Min/Max over variables, and Lookup

7 years ago
Do you mean sorting an array from highest to lowest? If so, then yes, you can do it with If/Then scripting.

Min/Max over variables, and Lookup

7 years ago

Array sorting is the first half, array lookup is the second

Sorting to find the target (here min / max value), and preferably array lookup to find the related field (name of faction) to the reference value (loyalty points). Without an array lookup will need to run a second variable to store the name of the faction with the highest loyalty (up to that point in the loop), which is clumsy

Min/Max over variables, and Lookup

7 years ago
Sadly the clumsy way is the only way. Faster way is probably to check for the largest value while you do the sorting though, since by the end it would have seen all the values and could keep track of the highest/lowest/etc.