Confusion with highest underlined relationships and highest underline Calc

Ahh. OK. I thought you were saying the issue was that relationship D was coming out as the top one, when it shouldn’t have been. Out of the four relationships, d is set to the highest (4), so it looks right to me. Unless I’ve missed something.

So, The reason for the _1/_2/_3 etc. is to allow you to loop through the variables quickly using the array function in choice script. The loop looks like this:

*label highest_relationship_calc
*temp relationship_counter 1
*label relationship_calc_loop
*if Relationship_counter <= Total_relationships
*if rel[Relationship_counter] > Highest_relationship_stat
	*set Highest_relationship_stat rel[Relationship_counter]
	*set highest_rel rel_name[Relationship_counter]
	*set Relationship_counter + 1
	*goto Relationship_calc_loop
*return

When you put a variable in then what it does is takes the value of that variable, puts an _ in front of it and appends it to the end of the string before it and makes a new variable name. So rel[Relationship_counter] becomes rel_1 (or 2, or 3…)

On iteration 1 of your loop (relationship_counter = 1), your code becomes like this:

*label highest_relationship_calc
*temp relationship_counter 1
*label relationship_calc_loop
*if 1 <= 4
*if rel_1 > Highest_relationship_stat
	*set Highest_relationship_stat rel_1
	*set highest_rel rel_name_1
	*set Relationship_counter + 1
	*goto Relationship_calc_loop
*return

Then it increases relationship_counter by 1 (to 2) and we loop again:

*label relationship_calc_loop
*if 2<= 4
*if rel_2 > Highest_relationship_stat
	*set Highest_relationship_stat rel_2
	*set highest_rel rel_name_2
	*set Relationship_counter + 1
	*goto Relationship_calc_loop
*return

And so on for 3 and 4 - then the loop stops at 5, because 5 is not <= 4.

So yes, the variable names should say like that if you want to use the simple looping method. Alternatively you could give the variables all different names, then you just need to write an *if statement for each relationship

2 Likes