Text variable shows up different in game than in stats file

I am trying to make the ‘suspicion’ bar appear with different text depending on the scene. So I am using if statements based on the variable ‘scene’ to change the text. The problem is the stats screen shows the variable as something else than when I reference it in-game.

When the scene variable is shown on the stats page, it shows the variable as ‘object Object’. However, I have tested the variable by placing it in-game as ${scene} and it shows the correct scene: ‘heist’.

My code in the stats file:

[b] Character Information [/b]
*if (scene = "heist")
	*stat_chart
		text name
		text gender
		percent suspicion Attention
*elseif (scene = "interrogation")
	*stat_chart
		text name
		text gender
		percent suspicion Combativeness
*else
	*stat_chart
		text name
		text gender
		percent suspicion Suspicion
		text scene

It always goes to the last *else because choicescript isn’t interpreting the scene as ‘heist’
2019-03-31

My code in the heist scene file:

*set scene "heist"
${scene}

Here the scene variable appears correctly as ‘heist’.

Do you mind posting the screenshot of your stats screen in action?
It’s hard to figure out which one your stats screen is showing without picture.

1 Like

Yeah, and showing a general idea of what the code, in general, looks like could be helpful as well. If this is embedded deep within other else statements, it could just be skipping to the first “true” statement.

Hmm, so the stats screen doesn’t receive the change made to [scene].
Just curious, but that’s all the code inside your stats screen, right?

And just in case. In your startup.txt, did you declared the variable correctly? e.g.

*create scene ""

And not a blank *create scene?

Sure, I edited it in there.

My startup.txt declared the variable as:

*create scene "x"

Just tried that, now I get there error “It is illegal to fall in to an *else statement; you must *goto or *finish before the end of the indented block”. Which is odd because I didn’t think you needed a *goto or *finish in the stats screen (at least it worked before when I didn’t have that), but I’ll try fixing that now.

That worked!
2019-03-31%20(2)

*if (part = "heist")
	*stat_chart
		text name
		text gender
		percent suspicion Attention
		text part
	*goto continue
*elseif (part = "interrogation")
	*stat_chart
		text name
		text gender
		percent suspicion Combative
	*goto continue
*else
	*stat_chart
		text name
		text gender
		percent suspicion Suspicion
	*goto continue

*label continue

Lesson learned, don’t use ‘scene’ as a variable. I changed the variable to ‘part’ and now it works! Thanks a bunch. (updated to include the new variable shown)

It’s not CS hiccupping because the var is called “scene” is it?

Just to make sure: if there’s not too much to search and replace could you check what happeny if you rename the var to something else?

Oh, btw if you just want *if to display something in stats you can just use *if each time, so you wont need gotos

Also, should this go into the wiki that naming a var scene makes CS hiccup?

Edit: mnnn you removed the var though. Could you try what happens if you put the renamed one there?

Like

text scenery
1 Like

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