So at the moment I’m trying to make something work where in the player’s stat screen, there is a little bit of text that changes depending on what their highest stat is at that time.
I’ve figured out how to accomplish this with another wonderful user’s–Vendetta’s–code, which I have graciously stolen. At the moment, it looks a bit like this:
And so on and so forth with the rest of the stats in my game, with a *gosub in the stats menu to re-run this check whenever needed. However, it occurred to me that there might be a problem if two stats happen to be exactly equal. I’d like for the game to randomly select one out of the stats that are equal to display that stat’s little line of text, but I’m not sure how to accomplish this. Something with *rand and *if charm = mainstatval or something like that? But I am not skilled in CS enough to have a go at it on my own.
If anyone has any ideas it would be much appreciated. Thanks so much in advance!
First of all, I would recommend keeping the complexity of the code low use the >= operator to choose a stat if they are equal, so it becomes something like this
The only difference is that equal values aren’t randomised, it just sticks with the first encountered one instead. Which is probably fine for most use cases?
I…admittedly, did not consider the first solution, which would work just fine for my purposes, however these are both excellent. Thank you so so much!!
@alphayash@halfmooncroissant There is a mistake in the second code snippet I provide, it will set the max only if tie-breaker is 1 even if the stat is greater. To fix it, just do this