Seeming to jump a *if

So, I have a bunch of *if’s involving highest_relationships, but it keeps going to one in particular, even when I alter the relationships in the startup file where that one doesn’t have the highest relationship, and am now confused what’s going on.
The code for the *if’s looks like this:

*label reassurance
*if (highest_relationship) = "t_relationship"
	*goto t_reassure
*elseif (highest_relationship) = "l_relationship"
	*goto l_reassure

*elseif (highest_relationship) = "n_relationship"
	*goto n_reassure
*elseif (highest_relationship) ="d_relationship"
	*goto d_reassure

Right now, it’s defaulting to t_reassure, even when I have t’s relationship at 50 and one of the others at 60. So yeah, I’m a little confused on what’s happening here.
Don’t think I have anything set up that would alter the relationships, as I have the test file jump streight to reassurance, so yeah.
Hope that someone can give me a second opinion?

can you show us the code that sets “highest_relationship”?


I’m not overly familiar with choicescript but if it’s anything like other programming languages you need to move your second parentheses ) to the end of the condition statement.

As @shancall pointed out (i didn’t notice it before) but you need to rewrite the checks to the following

*label reassurance
*if (highest_relationship = t_relationship)
	*goto t_reassure
*elseif (highest_relationship = l_relationship)
	*goto l_reassure
*elseif (highest_relationship = n_relationship)
	*goto n_reassure
	*goto d_reassure

Ok so, knowing how you determine highest_relationship and what its set to would be helpful.

In this case, the parenthesis don’t actually matter, it works either way, at least in IDE, but it does look prettier the way Nocturnal Stillness said.

As written, its asking if the variable highest_relationship has the value “t_relationship” assigned to it. Its not doing anything to look at what values are stored in each _relationship stat. I’m guessing you’d want to have code somewhere checking each relationship value against eachother and saving that to highest_relationship before this if statement.

This a really messy solution (almost certainly a cleaner way to do it) but if you copy paste this right before your if statements (it checks which variable is the highest and sets highest_relationship to that name of that variable) it should work:

*set highest_relationship "t_relationship"
*if (t_relationship > "${{highest_relationship}}")
    *set highest_relationship "t_relationship"
    *goto end_rel_check
*if (l_relationship > "${{highest_relationship}}")
    *set highest_relationship "l_relationship"
    *goto end_rel_check
*if (n_relationship > "${{highest_relationship}}")
    *set highest_relationship "n_relationship"
    *goto end_rel_check
*if (d_relationship >"${{highest_relationship}}")
    *set highest_relationship "d_relationship"
    *goto end_rel_check
*label end_rel_check

If you plan on having multiple relationship checks throughout your book, you probably want some kind of script file text file and just go to that scene/label every time you want to set highest_relationship.

1 Like
*label highest_stat_calc
*set stat_counter 1
*label stat_calc_loop
*set stat_1 combat
*set stat_name_1 "combat"
*set stat_2 perception
*set stat_name_2 "perception"
*set stat_3 people
*set stat_name_3 "people"
*set stat_4 tech
*set stat_name_4 "tech"
*if Relationship_counter <= Total_relationships
    *if relationship[Relationship_counter] > Highest_relationship_stat
        *set Highest_relationship_stat relationship[Relationship_counter]
        *set highest_relationship relationship_name[Relationship_counter]
    *set Relationship_counter + 1
    *goto stat_calc_loop

To be fare, I was never particularly good on knowing what most of that does. I get the over-all basicks, but nothing like the rest of the choice script.

Nothing in that code seems to set the actual relationships you are checking for. So that might be the issue? If it doesn’t actually check the highest relationship it would drop out of the *if block which ends up showing the text below it which would be *label t_assure

I tried to set that last one, as it’s in another text file, to track which relationships are highest, and use that.
It’s with the *gosub_scene variable.

Basickly I intended it to track each fluctuation in relationships by using the *gosub_scene variable, then have it use that file to check to see which relationship is currently the highest.
Seemed to work fine when I was checking which relationship was higher than another, so I’m not quite sure what’s going wrong now?

Maybe try adding a few lines that show the relationship stats


T relationship: ${t_relationship}

And see if the variables are getting set correctly.

My advice would be to spend some time understanding exactly how that code works. I just looked back and I originally wrote that piece of code for you two years ago. Since then I have seen at least 10 threads where you have encountered issues using it.

As has been suggested above and I suggested the other day, printing out the values of the variables is a great way of seeing what state everything is in at any one time. It also greatly assists in understanding what the code is doing.

The original code was written to take all relationship stats, which are a number and identify which number is the highest. That relationship is then recorded as the highest one


Why does this code set several stat-related variables, never check them, and then loop back and reset them again? Am I missing something? Did you copy some code and then edit it without understanding the functionality?

Firstly, turns out that I had the wrong code, as this, is my actual highest relationship calculations:

*label best_stat
*set relationship_counter 1
*label relationship_calc_loop
*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}
*if Relationship_counter <= Total_relationships
    *if relationship[Relationship_counter] > Highest_relationship_stat
        *set Highest_relationship_stat relationship[Relationship_counter]
        *set highest_relationship relationship_name[Relationship_counter]
    *set Relationship_counter + 1
    *goto relationship_calc_loop

I think that I am missing something, as ${highest_calc} doesn’t seem to print out the highest relationship, but I can’t think of exactly how to fix that. Frustrated sigh.

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