This is maybe going to be long. Also this code is kinda… not amazing, I can see multiple problems that could crop up immediately.
This section goes the arrays to look at each relationship value. Basically it has a variable “Highest_relationship_stat” which is tracking the highest relationship stat seen so far and “highest_relationship” which is tracking the name of the person that has the relationship value in Highest_relationship_stat. For each relationship, its checking if its higher than the one currently stored. If it is, than that relationship number and person name become the new highest_relationship_stat and highest_relationship.
The Long Explanation - Line by Line
Here I’m going to go line by line with hypothetical values
Going into this, lets assume
t_relationship: 60
t_name: Taylor
l_relationship: 50
l_name: Lana
n_relationship: 70
n_name: Nathan
d_relationship: 65
d_name: Dylan
v_relationship: 80
v_name: Vera
Total_relationships: 5
Also, going into this, idk, start with:
Highest_relationship_stat: 0
highest_relationship: noname
*set relationship_counter 1
This gives you a variable
relationship_counter: 1
*label relationship_calc_loop
This creates a marker “relationship_calc_loop” that the code will direct to go to at a later point.
*set relationship_1 t_relationship
This is an array “relationship”
relationship[1]: t_relationship
with the example values given,
relationship[1]: 60
*set relationship_name_1 “${t_name}”
This is a second array “relationship_name” where
relationship_name[1]: t_name
with the example values given, you have
relationship_name[1]: Taylor
*set relationship_2 l_relationship
*set relationship_name_2 “${l_name}”
Similar principle. After running this, with the example values given you would now have:
relationship[1]: 60
relationship[2]: 50
relationship_name[1]: Taylor
relationship_name[2]: Lana
you’ll notice that these values correspond to the relationship value and names of t and l.
*set relationship_3 n_relationship
*set relationship_name_3 “${n_name}”
*set relationship_4 d_relationship
*set relationship_name_4 “${d_name}”
*set relationship 5 v_relationship
*set relationship_name_5 "${v_name}
Same concept for this section, by the end of it, you’ll have:
relationship[1]: 60
relationship[2]: 50
relationship[3]: 70
relationship[4]: 65
relationship[5]: 80
relationship_name[1]: Taylor
relationship_name[2]: Lana
relationship_name[3]: Nathan
relationship_name[4]: Dylan
relationship_name[5]: Vera
each index of the array represents a person. t is at position 1, so if you check the two arrays, the relationship with t is 60 and t’s name is Taylor. d is in position 4, the relationship with d is 65 and d’s name is Dylan.
Here is the more involved part:
*if Relationship_counter <= Total_relationships
This checks if your relationship counter is either smaller than, or equal to the number of relationships. If it is, it runs what is nested underneath, if not, skips everything nested and goes to the return.
At this point, “relationship_counter” is 1 and “Total_relationships” is 5. Since 1 is less than or equal to 5, the indented code underneath runs.
*if relationship[Relationship_counter] > Highest_relationship_stat
This now checks the relationship. Its looking if the value in the "relationship_counter"th position of “relationship” is greater than “Highest_relationship_stat”. If it is, it runs the code indented beneath it. If it is smaller than or equal to “Highest_relationship_stat” the code goes to *set Relationship_counter
.
In our example, Highest_relationship_stat is 0. relationship_counter is 1 so its checking relationship at the 1st postion. relationship[1] is 60. 60 is greater than 0 so the if statement is true and the code indented under it runs.
*set Highest_relationship_stat relationship[Relationship_counter]
*set highest_relationship relationship_name[Relationship_counter]
Now this runs. It now sets “Highest_relationship_stat” to whatever value was stored in the position of “relationship” you were currently looking at. “highest_relationship” is set to the corresponding name.
In our example, going into this Highest_relationship_stat is set to the value in relationship[1], Highest_relationship_stat is now 60. highest_relationship is set to the value at relationship_name[1], highest_relationship is now “Taylor”.
Ending of this:
Highest_relationship_stat: 60
highest_relationship: Taylor
*set Relationship_counter + 1
This adds 1 to the variable “Relationship_counter”.
In our example, Relationship_counter was 1. After adding 1 to it, Relationship_counter is now 2, indicating that next time we will be looking at the 2nd position in the arrays.
*goto relationship_calc_loop
This is telling the computer to go allllll the way back to the *label relationship_calc_loop
earlier in the code.
*set relationship_1 t_relationship
*set relationship_name_1 “${t_name}”
*set relationship_2 l_relationship
*set relationship_name_2 “${l_name}”
*set relationship_3 n_relationship
*set relationship_name_3 “${n_name}”
*set relationship_4 d_relationship
*set relationship_name_4 “${d_name}”
*set relationship 5 v_relationship
*set relationship_name_5 "${v_name}
runs again, no different from before, just setting the values in the arrays again.
*if Relationship_counter <= Total_relationships
Checks this again. In the current example, Relationship_counter is still less than total relationships, so everything indented runs.
*if relationship[Relationship_counter] > Highest_relationship_stat
In our example, relationship[2] is 50 and Highest_relationship_stat is 60. 50 is LESS THAN 60 so the code under this does not run.
*set Relationship_counter + 1
*goto relationship_calc_loop
Same as before, goes back to *label relationship_calc_loop
but this time, Relationship_counter is 3, meaning we’re looking at the 3rd position.
*set relationship_1 t_relationship
*set relationship_name_1 “${t_name}”
*set relationship_2 l_relationship
*set relationship_name_2 “${l_name}”
*set relationship_3 n_relationship
*set relationship_name_3 “${n_name}”
*set relationship_4 d_relationship
*set relationship_name_4 “${d_name}”
*set relationship 5 v_relationship
*set relationship_name_5 "${v_name}
Does this again
*if Relationship_counter <= Total_relationships
Is 3 less than 5? Yes? Runs indented code
*if relationship[Relationship_counter] > Highest_relationship_stat
relationship[3] is 70, Highest_relationship_stat is 60. 70 greater than 60? Yes? Run indented code.
*set Highest_relationship_stat relationship[Relationship_counter]
*set highest_relationship relationship_name[Relationship_counter]
After running,
Highest_relationship_stat: 70
highest_relationship: Nathan
*set Relationship_counter + 1
*goto relationship_calc_loop
Do it again but relationship counter is now 4, look at the 4th position.
*set relationship_1 t_relationship
*set relationship_name_1 “${t_name}”
*set relationship_2 l_relationship
*set relationship_name_2 “${l_name}”
*set relationship_3 n_relationship
*set relationship_name_3 “${n_name}”
*set relationship_4 d_relationship
*set relationship_name_4 “${d_name}”
*set relationship 5 v_relationship
*set relationship_name_5 "${v_name}
This runs again
*if Relationship_counter <= Total_relationships
Is 4 less than or equal to 5? Yes? Do the stuff indented.
*if relationship[Relationship_counter] > Highest_relationship_stat
relationship[4] is 65, Highest_relationship_stat is 70. 65 < 70? No? Skip indented.
*set Relationship_counter + 1
*goto relationship_calc_loop
Do it again but Relationship_counter is 5, look at 5th position.
*set relationship_1 t_relationship
*set relationship_name_1 “${t_name}”
*set relationship_2 l_relationship
*set relationship_name_2 “${l_name}”
*set relationship_3 n_relationship
*set relationship_name_3 “${n_name}”
*set relationship_4 d_relationship
*set relationship_name_4 “${d_name}”
*set relationship 5 v_relationship
*set relationship_name_5 "${v_name}
This again
*if Relationship_counter <= Total_relationships
Is 5 less than or equal to 5? Equal to? Run indented.
*if relationship[Relationship_counter] > Highest_relationship_stat
relationship[5] is 80, Highest_relationship_stat is 70. 80 > 70? Yes? Run indented.
*set Highest_relationship_stat relationship[Relationship_counter]
*set highest_relationship relationship_name[Relationship_counter]
After running this,
Highest_relationship_stat: 80
highest_relationship: Dylan
*set Relationship_counter + 1
*goto relationship_calc_loop
Do it again but relationship_counter is 6
*set relationship_1 t_relationship
*set relationship_name_1 “${t_name}”
*set relationship_2 l_relationship
*set relationship_name_2 “${l_name}”
*set relationship_3 n_relationship
*set relationship_name_3 “${n_name}”
*set relationship_4 d_relationship
*set relationship_name_4 “${d_name}”
*set relationship 5 v_relationship
*set relationship_name_5 "${v_name}
This again
*if Relationship_counter <= Total_relationships
Relationship_counter is 6, Total_relationships is 5. Is 6 greater than or equal to 5? No? Skip intented and go to the *return
*return
code is over
By the end of this
Highest_relationship_stat is 80
highest_relationship is "Dylan.