Having the game check numerical values in a group of stats?

So, I have character attitudes in my game that let you see how fondly a character thinks of you, or rather how often you pick choices that tickle their fancy. In any case, I was wondering how one would take a group of stats (eliatt, harpatt, saratt, krisatt) and have the game check which one of them is say, the second highest. I have zero idea of how to even start doing this, so help would be much appreciated!

Summary: I want to know how to make the game check for the second highest numerical value in a group of four stats.

You can either run a sub to compare the relationship stats, or have a counter count how often you pick a choice they favour, and compare that.

Like

*if a > b
   *if a > c
      *if a > d
         *set highest "a"
      *if a < d
         *set highest "d"
      *if a = d
         *set highest "ad"
   *if a < c
etc

and then check for the remaining the same way:

*if (highest =a)
   *if b > c
      *if b > d
         *set second "b"
etc

it can get a quite long subroutine, but that’s the only way right now iirc

5 Likes

That is a very lengthy subroutine, and I am suddenly glad I am doing four love interests instead of six for my first book series.

That being said, thank you so much, this is super cool! I can also apply what you’ve taught me here to help with my updating clues screen on one of my stats pages!

1 Like

thanks for the awesome information.

There might be a shorter way with parameters, but I have no idea how to do those.

I don’t know if this is really better, or shorter, but here is a loop which should handle any number of values and put them in numerical order for you - each one in a variable which you then refer to.

You would call this with *gosub order_calculation.
It is critical for it to reset the top_x variables to 0 each time.

To get it to work with different numbers of variables, you just create additional att_X and top_X variables and increase/decrease the *if counter <7 and *set counter2 6 lines accordingly.

*create att_1 8
*create att_2 9
*create att_3 4
*create att_4 6
*create att_5 3
*create att_6 1

*create att_99 0

*create top_1 0
*create top_2 0
*create top_3 0
*create top_4 0
*create top_5 0
*create top_6 0

*label order_calculation
*set top_1 0
*set top_2 0
*set top_3 0
*set top_4 0
*set top_5 0
*set top_6 0

*temp counter 1
*temp counter2 6
*temp store_counter 0
*temp store_att_number 0


*label loop_start
*if counter < 7
    *label second_loop_start
    *if counter2 > 0
        *if att[counter] > top[counter2]
            *if top[counter2] = 0
                *set top[counter2] att[counter]
                *set att_99 0
                *if counter = 99
                    *set counter store_counter
                *set counter + 1
                *set counter2 6
                *goto loop_start
            *else
                *set counter2 -1
                *goto second_loop_start            
        *else
            *if att_99 != 0
                *set store_att_number top[counter2]
                *set top[counter2] att[counter]
                *set att_99 store_att_number
            *if att_99 = 0
                *set att_99 top[counter2]                
                *set top[counter2] att[counter]
                *set store_counter counter
            *set counter 99
            *set counter2 6
            *goto second_loop_start
        
First: ${top_1}, 
Second: ${top_2}, 
Third: ${top_3}, 
Fourth: ${top_4}, 
Fifth: ${top_5}, 
Sixth: ${top_6}

*return
2 Likes

When it comes to sorting the variables based on their value, you can also check out the subroutine written by stainedofmind here

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.