Mixed results in a test?

I’m having trouble with getting mixed results on the same page in a personality test I’ve designed for Prismatic.

This is the chapter scene: https://dashingdon.com/play/pinks/prismatic/mygame/scenes/chapter1.txt

This is the code for determining the test results:

Code

*set colorset true
*temp top_stat
*temp highest_stat
*set top_stat red
*set highest_stat “red”

*if orange > top_stat
*set top_stat orange
*set highest_stat “orange”
*if yellow > top_stat
*set top_stat yellow
*set highest_stat “yellow”
*if green > top_stat
*set top_stat green
*set highest_stat “green”
*if cyan > top_stat
*set top_stat cyan
*set highest_stat “cyan”
*if blue > top_stat
*set top_stat blue
*set highest_stat “blue”
*if purple > top_stat
*set top_stat purple
*set highest_stat “purple”

All the results start like this: *if top_stat = red/orange/yellow/etc.

I tried using page_break before displaying the results, but it didn’t help. Would inserting a fake_choice between the code and the results fix the issue?

Two things:

First, what actual result are you getting, and what’s your expected result? It’s not clear to me from your post.

Second, please use the “preformatted text” button in the text editor (looks like this: </>) to show us your code with the indentations. So much of CS’s logic depends on correct indentations that it’s very difficult to judge why the code doesn’t work without it.

1 Like

Sorry, here:

*set colorset true
*temp top_stat
*temp highest_stat
*set top_stat red
*set highest_stat "red"

*if orange > top_stat
  *set top_stat orange
  *set highest_stat "orange"
*if yellow > top_stat
  *set top_stat yellow
  *set highest_stat "yellow"
*if green > top_stat
  *set top_stat green
  *set highest_stat "green"
*if cyan > top_stat
  *set top_stat cyan
  *set highest_stat "cyan"
*if blue > top_stat
  *set top_stat blue
  *set highest_stat "blue"
*if purple > top_stat
  *set top_stat purple
  *set highest_stat "purple"

  
*if top_stat = red
    [i][b]Thank you, ${name}, and congratulations, you are [i]red[/i], the color of callousness![/b][/i]
*if top_stat = orange
    [i][b]Thank you, ${name}, and congratulations, you are [i]orange[/i], the color of arrogance![/b][/i]

And so on.
There is a test where you can gain points for each color, and the results appear to show not one description, but multiple ones as long as you have multiple top options sharing the same number of points. I think I managed to fix it by tweaking with the code and creating an additional variable color:

*set color highest_stat
  
*if color = "red"
    [i][b]Thank you, ${name}, and congratulations, you are [i]red[/i], the color of callousness![/b][/i]

I don’t get multiple descriptions now during testing, but I haven’t tested extensively, and I’m still not sure what was causing the issue, so I don’t know if it really got fixed.

You’ve got two things going on here – the numeric stats (colors and top_stat) and the string highest_stat. You can have ties in the former, but the code doesn’t allow ties for the latter; even if red and orange are both 6, highest_stat will stay set to “red” because it’s only set to “orange” if orange is higher, not equal.

But what you had triggering the “Thank you, name, and congrats” text in your main code block was the numeric stats. In the hypothetical case where red and orange are both 6, then *if top_stat = red will trigger (because you *set top_stat red, i.e. 6) and *if top_stat = orange will also trigger (because both top_stat and orange are 6).

You can fix this without creating a new variable. All that’s needed is to replace

*if top_stat = red etc.

with

*if highest_stat = "red" etc.

That is, instead of using the stats that can be tied, use the one that will always have a single unique value. The fix you found, creating color, is just doing this through the backdoor.

2 Likes

I get it now, thank you! Didn’t know that it allows ties like that.

1 Like

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