"Hidden" stats, what am I doing wrong?

Hey everyone,

I’ve followed the directions on the choicescript home page dedicated to customising the stats screen, and it only partially works. I’m trying to figure out what I did wrong for the parts that don’t work since I haven’t changed anything.

Here’s the code I’m working with.

*temp title_r1 "???"
*temp title_r2 "???"
*temp title_r3 "???"
*if bestfriend = "Liz"
    *set title_r1 "Liz"
    *goto stat1
*if bestfriend = "Sam"
    *set title_r1 "Sam"
    *goto stat1
*if Natmet = true
    *set title_r2 "Nat"
    *goto stat1
*if Leomet = true
    *set title_r2 "Leo"
    *goto stat1
*if Kiramet = true
    *set title_r3 "Kira"
    *goto stat1
*else
    *label stat1
    *stat_chart
        percent r1 ${title_r1}
        percent r2 ${title_r2}
        percent r3 ${title_r3}

So it should look like this at the beginning (which it does):

However, when the conditions become true, only the first one, Liz or Sam, displays correctly.

The other two stat bars don’t show the name change if the correct conditions are met. I have checked the code multiple times to make sure the condition actually does become true and is spelled correctly, but to no avail. Does it not work with boolean variables or do I have it set up wrong?

I’m not sure what is causing the difference? I don’t want to hide it completely, I simply want the name to change from “???” to the relevant character’s name.

Thanks guys!

1 Like

Have you tried using *elseif ?

Yes, I’ve tried that but I’m still getting “???” for the last two bars.

Your problem is that you have a *goto set up after each *if statement. Because of this, the code automatically skips anything after the first true statement, resulting in those other variables not being changed appropriately.

You should be able to make do with just removing the *goto codes.

Wow okay, thank you very much. I don’t know why I couldn’t figure it out.

I previously had *else and *elseif in the statements which forced me to *finish or *goto before they ended, but I forgot that’s not required if you’re using only *if statements.

Thanks again so much!

1 Like
*temp title_r1 "???"
*temp title_r2 "???"
*temp title_r3 "???"
*set bestfriend "Liz"
*set leomet true
*set kiramet true
*if bestfriend = "Liz"
    *set title_r1 "Liz"
*if bestfriend = "Sam"
    *set title_r1 "Sam"
*if Natmet = true
    *set title_r2 "Nat"
*if Leomet = true
    *set title_r2 "Leo"
*if Kiramet = true
    *set title_r3 "Kira"
*label stat1
*stat_chart
    percent r1 ${title_r1}
    percent r2 ${title_r2}
    percent r3 ${title_r3}

Obviously wouldn’t need the *set commands I added after the *temp commands, but removing the *goto AND *else codes will fix the issue for you.

Yep! It worked perfectly once I got rid of both of those, thanks again!

Title. I’d like a stat to be invisible when a player enters the choicescript_stats menu unless a certain condition is met. Say, for example…

*if (encounter_bob = “true”)
(here is a code unbeknownst to me that would be entered to display a stat, maybe like “bob_relationship” if the condition “encounter_bob” is set to “true”)
*else
(code entered here to hide “bob_relationship” if “encounter_bob” is anything other than “true”)

Any idea of how I may accomplish this? Thank you so much!

You’re most of the way there already! It is as simple as putting the bob_relationship stat in an *if command. For instance:

*if encounter_bob
  *stat_chart
    percent bob_relationship Bob

You don’t even need the *else if you don’t have anything else to display in the meantime. The above code will make Bob’s relationship stat invisible until encounter_bob is set to ‘true’.

1 Like

Oh wow, great! Thank you so much!! :sweat_smile:

Just a quick question how do you add a stat but keep it hidden from the player screen?

@Nostalgiafan

I created a temp variable on the stat screen that I called “hiddenstat” aptly, lol, and used that to keep some stuff hidden. It seems to work fine for my purposes.

So *temp hiddenstat false

and then I made an *if statement over the stats I wanted hidden, for example:

*if hiddenstat = true
-> *stat_chart
–> text charm
–> text bold

The arrows are indents.

This is only if you want the stats hidden while you have a demo or are playtesting. If you want the stats hidden temporarily, you’ll want to make a real variable on your startup and use that instead of a temp

I’m wanting it for the whole game. I’m planning on having it effect certain outcomes depending on the score

@Nostalgiafan The *temp hiddenstat should work for the whole game then! Or you can just not add them to the stat page at all. As long as you have the stat in the startup, you don’t actually have to have it appear in the stats screen.