How do I check if the reader inputs the same thing in 2 different text inputs?

Hi,

So say I want reader to answer two questions; what is their character’s name and what is their character’s friend’s name. How do I check if they put the same name twice? I’d like a custom response if they try to make the name the same for both characters. This is just an example.

Here’s the code I am dealing with:

    NARRATOR
She looks lovely.
What is her name?

label name_input
input What’s your character’s name?|What’s your character’s name?|Done(NAME)
if (NAME is “”){
NARRATOR
Please input a name.
goto name_input
} else {
continue
}

    NARRATOR
I have another question for you.
What is YOUR name, reader?

label readername_input
input What is YOUR name?|What is YOUR name?|Done(READERNAME)
if (READERNAME is “”){
NARRATOR
Please input a name.
goto readername_input
} else {

}

if ([READERNAME] = [NAME]) {
NARRATOR
Ah…
You named your character after yourself, didn’t you?
Or maybe you didn’t want to give me your real name…
Either way, how interesting.
} else {

}

4 Likes

You can probably ask @Dara.Amarie about this because i remember others ask the same thing and i think this girl know how to do it. I’m not entirely positive btw, its a maybe. Plus this girl have a lot of cool stuff to learn and know :wink:

1 Like

Hey anyone have a solution for this?

Okay so I just tested some things and it looks like you can’t compare two inputs, just one. The only solution for this is that you don’t let them choose a name for the bf and then do it like this:

label choose_name
input What's your name? | What's your name? | Done (YOU)
if (YOU is "Hannah") {
NARRATOR
You can't have the same name as your best friend... Sorry.
goto choose_name
}else {
NARR
Hello, [YOU]. Welcome to the story!
}
2 Likes

Thank you, that solves one part of my issue :slight_smile:

Do you have a solution for if I want the reader to input two things?
I’ll show you my code:

    NARRATOR
She looks lovely.
What is her name?

label name_input
input What’s your character’s name?|What’s your character’s name?|Done(NAME)
if (NAME is “”){
NARRATOR
Please input a name.
goto name_input
} else {
continue
}

    NARRATOR
I have another question for you.
What is YOUR name, reader?

label readername_input
input What is YOUR name?|What is YOUR name?|Done(READERNAME)
if (READERNAME is “”){
NARRATOR
Please input a name.
goto readername_input
} else {

}

if ([READERNAME] = [NAME]) {
NARRATOR
Ah…
You named your character after yourself, didn’t you?
Or maybe you didn’t want to give me your real name…
Either way, how interesting.
} else {

}

This code doesn’t work. It displays the custom response regardless of if the names match or not.

Do you know how I can fix this?

You don’t need the part with “”. The reader can’t press “Done” without entering at least one character.

Yeah that’s because you can’t compare two inputs, like I said :sweat_smile:
You can only check if one input is “Something” or not. This really hurts my programmer soul :sob:

1 Like

Btw with the = comparison you check if the character’s points are the same as the other’s :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.