What does *if “${name}” != “$!{name}” do?

Hello, it’s me again. I hope that writing so many posts (two for now, but I’m a curious soul and choicescript has taken over my life ahah) isn’t a negative thing, I’m sorry in advance if I’m taking too much space in the forum. This community is very welcoming though, so that’s great.

Anyways, I’m studying the choice of dragon code to figure out if there’s anything new I can learn and I have a couple of questions

This line of code:
comment check capitalization
*if (“${name}” != “$!{name}”)

        Your name is $!{name}, is that right?

                *set name "$!{name}"
                *goto gender
            #No, my name is ${name}, just as I said.
                *goto gender
            #Er, wait, let me try that again.
                *goto input_name

I was wondering what exactly the line “ *if (“${name}” != “$!{name}”)”
does? I checked the wiki and I found that a similar code is what’s referred to as “comparing” but I’m still confused.
I also tried using it in my own choicescript file (the one I test things on don’t worry!) but I didn’t see any difference, so I don’t know.

Thank you in advance to anyone who replies! :slight_smile:

It checks if the content of variable name is the different from the capitalized content of the name variable.

For example, if name contains the value “tim”, then the evaluation of that stament will be true. If it’s “Tim”, it will be false because the values are the same.

1 Like

I’m sorry, I still don’t really get it :frowning:

What difference would it make if I didn’t use this line in my code?

Say the player types in “tim.”

CS will read the if statement and then correct it to Tim and ask the reader to confirm that Tim is correct.

To be more specific:
*if (“${name}” != “$!{name}”) notice the second ! in front of {name}. That capitalizes the {name} value, either saying “yes, they typed Tim so we’re good” or “no, they typed tim so let’s change it to Tim.”

The following lines allow the player to see that change and confirm or deny it.


It depends what you want to do, there isn’t a preset way to write code. If you don’t want anything to happen if a character’s name isn’t capitalized, you don’t have to use that line.


Most people will want to name their dragon something capitalized, even if they enter it in lower-case; they’d like the rest of the game to call them “Oh mighty Smaug!” not “Oh mighty smaug!”

But in case the reader wants a dragon named cummings or bell, this code lets them clarify that, with the “#No, my name is ${name}, just as I said.” Picking that choice confirms that they intentionally chose a lower-case name for their dragon.

Like @quartz says, the line might not be relevant for you. Maybe you want to always capitalize the MC’s name (in which case you could code it as $!{name} throughout, or have a *set name "$!{name}" line like CoD). Or maybe you’re happy for players who input text for their name to live with whatever capitalized or lower-case name they type in.


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