0 votes
asked by (710 points)

I have a running score counter in my game and at the game-over screen I'd like to not only display the score, but display ONLY the single appropriate rating.

Thus far I've got the score to add up and display and the rating. However I'm unable to think or code a way to display the score rating for just one of the ratings. If that makes any sense?

When the code runs it displays every score rating once the score goes above a certain value.

 

Your adventure has come to an end.

You have scored: 

<<print $score>>

That kind of score earns you the rank of:

<<if $score >= 3>><<print "Village Idiot">><</if>>
<<if $score >= 5>><<print "Simpleton">><</if>>
<<if $score >= 10>><<print "Likely Lad">><</if>>

I think maybe the greater than but lesser than is the answer, but my math code isn't very good on this.

1 Answer

0 votes
answered by (16.7k points)

Instead of having all of these be seperate <<if>> clauses, make it a single one:

Your adventure has come to an end.

You have scored: 

<<print $score>>

That kind of score earns you the rank of:

<<nobr>>
<<if $score >= 10>>
Likely Lad
<<elseif $score >= 5>>
Simpleton
<<elseif $score >= 3>>
Village Idiot
<</if>>
<</nobr>>

You also don't need to use <<print>> for a simple string, which is why I removed it above. Also, wrapping something into a <<nobr>> helps you to avoid unwanted breaks (if you want to make a break within the <<nobr>> make it by using <br>).

commented by (710 points)

Thanks Idling.

How would I code if I have 3+ ratings? Same way?

Your adventure has come to an end.

You have scored: 

<<print $score>>

That kind of score earns you the rank of:

<<nobr>>
<<if $score >= 100>>
SupermanLad
<<elseif $score >= 90>>
Superboy
<<elseif $score >= 80>>
Demigod
<<elseif $score >= 70>>
Hero
<<elseif $score >= 60>>
Striver
<<elseif $score >= 50>>
Average Joe
<</if>>
<</nobr>>

 

commented by (16.7k points)
Yes - you can add as many items you like using the same principle. I'm also pretty sure you don't need to write <<print $score>> just $score should work just as well. You only need print once the expression becomes more complex - usually something involving an array, e.g. $arrayname[$variable -1]
commented by (58.8k points)
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...