# Struggling with Name Input

**URL:** <https://forum.choiceofgames.com/t/struggling-with-name-input/62885>\
**Category:** ChoiceScript Help\
**Created:** [August 21, 2019, 5:01am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885 "2019-08-21T05:01:35Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![HeadUnderwater](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/headunderwater/32/98187_2.png) [@HeadUnderwater](https://forum.choiceofgames.com/u/HeadUnderwater)\
**Post date:** [August 21, 2019, 9:04am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/21 "2019-08-21T09:04:21Z")

</div>

Okay, great news, it started working!!

 ![image](https://global.discourse-cdn.com/choiceofgames/original/3X/3/8/38c021c3cfd86248c65489c3e461533bee03b021.png)

---

<div class="post-metadata">

**Author:** ![trevers17](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/trevers17/32/127415_2.png) [@trevers17](https://forum.choiceofgames.com/u/trevers17)\
**Post date:** [August 21, 2019, 2:40pm UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/22 "2019-08-21T14:40:00Z")

</div>

Do you mind saying what helped you figure it out?

---

<div class="post-metadata">

**Author:** ![HeadUnderwater](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/headunderwater/32/98187_2.png) [@HeadUnderwater](https://forum.choiceofgames.com/u/HeadUnderwater)\
**Post date:** [September 1, 2019, 5:24pm UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/23 "2019-09-01T17:24:50Z")

</div>

Oh, I believe I stopped using the “:” next to the input part, I hope this helps! \<3

---

<div class="post-metadata">

**Author:** ![Leodaire](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/leodaire/32/65468_2.png) [@Leodaire](https://forum.choiceofgames.com/u/Leodaire)\
**Post date:** [October 11, 2019, 6:41am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/24 "2019-10-11T06:41:09Z")

</div>

I really don’t know how to do this??? I’m trying to make it so for the default people can just put a name in for their character’s name and I did the whole

\*create\_player 0  
input\_text\_player\_name  
\*set player\_name “{player\_name}”

but like when i try and run it nothing happens, i dont get an error it just shows up when i try and put in a name as “{player\_name}” I’m really not sure where I went wrong or how to yknow make it work

---

<div class="post-metadata">

**Author:** ![Nahim\_Kerman](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/nahim_kerman/32/62734_2.png) [@Nahim\_Kerman](https://forum.choiceofgames.com/u/Nahim_Kerman)\
**Post date:** [October 11, 2019, 7:14am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/25 "2019-10-11T07:14:24Z")

</div>

Mmmm

How about:

```
*create_player 0
*Create player_name ""
*temp name ""

input_text name
(...)

*set player_name name

```

Like this?

---

<div class="post-metadata">

**Author:** ![anon8836198](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@anon8836198](https://forum.choiceofgames.com/u/anon8836198)\
**Post date:** [October 11, 2019, 8:05am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/26 "2019-10-11T08:05:55Z")

</div>

Why use an additional temp though?

```
*create fname ""
*create lname ""

First name?
*input_text fname
Last name?
*input_text lname

$!{fname} $!{lname}

```

---

<div class="post-metadata">

**Author:** ![lunawisp](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/lunawisp/32/85423_2.png) [@lunawisp](https://forum.choiceofgames.com/u/lunawisp)\
**Post date:** [October 11, 2019, 2:51pm UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/27 "2019-10-11T14:51:38Z")

</div>

Ello! Looks as if you’re trying to set player\_name to itself. This is the way I’d do it:

```
*temp p_entry ""
*input_text p_entry
    *if (p_entry != "")
        *set player_name "$!{p_entry}"

```

Check for nothing being entered so that you don’t set a blank name.  
Then when it’s set, use an exclamation point to capitalise it.

---

<div class="post-metadata">

**Author:** ![Myrtle](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/myrtle/32/99678_2.png) [@Myrtle](https://forum.choiceofgames.com/u/Myrtle)\
**Post date:** [October 11, 2019, 2:55pm UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/28 "2019-10-11T14:55:07Z")

</div>

> [@Having issues inputting names?](https://forum.choiceofgames.com/t/having-issues-inputting-names/66994/4):
>
> Check for nothing being entered so that you don’t set a blank name.

Is it possible for the player to enter nothing, though? When I play COGs, I always get the “Don’t just leave it blank! Type something!” pop-up. Or does that have to be programmed separately?

---

<div class="post-metadata">

**Author:** ![lunawisp](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/lunawisp/32/85423_2.png) [@lunawisp](https://forum.choiceofgames.com/u/lunawisp)\
**Post date:** [October 11, 2019, 2:59pm UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/29 "2019-10-11T14:59:19Z")

</div>

You’d have to put in some response to a blank. Just a message and a goto back to a label before the input or just leaving it as it was before. That was just a code snippet from my latest ‘not so epic’ missive. The \*if statement makes the change to the entered name if there was one. If it was left blank, nothing changes.

```
*temp p_entry ""
*label try_again
*input_text p_entry
    *if (p_entry != "")
        *set player_name "$!{p_entry}"
    *else
        "Nothing entered - try again!"
        *goto try_again

```

Note, I haven’t tested that but it looks ok LOL

I don’t usually do this though. A character rename is usually off a choice option. If nothing is entered, I just don’t change anything. Then the code just returns to a point before the choice so the player can try again or do something else.

---

<div class="post-metadata">

**Author:** ![anon8836198](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@anon8836198](https://forum.choiceofgames.com/u/anon8836198)\
**Post date:** [October 11, 2019, 4:24pm UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/30 "2019-10-11T16:24:05Z")

</div>

It isn’t really necessary since CS has a built-in check to prevent blank inputs from both input\_text and input\_number. This condition \*if (p\_entry != “”) is impossible to meet in the game.

---

<div class="post-metadata">

**Author:** ![lunawisp](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/lunawisp/32/85423_2.png) [@lunawisp](https://forum.choiceofgames.com/u/lunawisp)\
**Post date:** [October 11, 2019, 4:49pm UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/31 "2019-10-11T16:49:13Z")

</div>

Huh. After all this time I never noticed that. All that extra typing for nothing. Learn something new every day 🙂

I’d rather it didn’t force you to enter things though, if your player makes a mistake they can’t back out of it by just hitting enter. This is the sort of thing that I think should be left for the user to code. Still, as Dilbert’s pointy haired boss once said, “It is what it is.”

---

<div class="post-metadata">

**Author:** ![Leodaire](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/leodaire/32/65468_2.png) [@Leodaire](https://forum.choiceofgames.com/u/Leodaire)\
**Post date:** [October 12, 2019, 2:23am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/32 "2019-10-12T02:23:31Z")

</div>

thank you all for replying to this and i apologize i should’ve also said that i’m using choice script ide, i did try those solutions but they didn’t seem to help

---

<div class="post-metadata">

**Author:** ![Nahim\_Kerman](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/nahim_kerman/32/62734_2.png) [@Nahim\_Kerman](https://forum.choiceofgames.com/u/Nahim_Kerman)\
**Post date:** [October 12, 2019, 2:32am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/33 "2019-10-12T02:32:07Z")

</div>

What exactly you are trying? I ask because I didn’t know if I get what you meant up there. 😃

---

<div class="post-metadata">

**Author:** ![Leodaire](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/leodaire/32/65468_2.png) [@Leodaire](https://forum.choiceofgames.com/u/Leodaire)\
**Post date:** [October 12, 2019, 3:01am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/34 "2019-10-12T03:01:37Z")

</div>

I’m just wanting to make it so people can enter in a name and it shows up

---

<div class="post-metadata">

**Author:** ![Szaal](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/szaal/32/112202_2.png) [@Szaal](https://forum.choiceofgames.com/u/Szaal)\
**Post date:** [October 12, 2019, 3:13am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/35 "2019-10-12T03:13:56Z")

</div>

Shows up as in `Your name: ${name}`?

---

<div class="post-metadata">

**Author:** ![Leodaire](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/leodaire/32/65468_2.png) [@Leodaire](https://forum.choiceofgames.com/u/Leodaire)\
**Post date:** [October 12, 2019, 3:19am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/36 "2019-10-12T03:19:58Z")

</div>

yeah

---

<div class="post-metadata">

**Author:** ![Szaal](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/szaal/32/112202_2.png) [@Szaal](https://forum.choiceofgames.com/u/Szaal)\
**Post date:** [October 12, 2019, 5:17am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/37 "2019-10-12T05:17:19Z")

</div>

Well, just do that.

```
*input_text name
Your name: ${name}
*choice
  #confirm
  #Re-enter

```

---

<div class="post-metadata">

**Author:** ![Leodaire](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/leodaire/32/65468_2.png) [@Leodaire](https://forum.choiceofgames.com/u/Leodaire)\
**Post date:** [October 12, 2019, 5:24am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/38 "2019-10-12T05:24:34Z")

</div>

i tried i got a nonexistent variable ‘name’ error

---

<div class="post-metadata">

**Author:** ![Myrtle](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/myrtle/32/99678_2.png) [@Myrtle](https://forum.choiceofgames.com/u/Myrtle)\
**Post date:** [October 12, 2019, 5:48am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/39 "2019-10-12T05:48:08Z")

</div>

You will need a `*create name ""` in your startup file. (You could also declare the variable as a temp, but since presumably you will want to keep using the name throughout the game, startup is best).

---

<div class="post-metadata">

**Author:** ![Szaal](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/szaal/32/112202_2.png) [@Szaal](https://forum.choiceofgames.com/u/Szaal)\
**Post date:** [October 12, 2019, 7:04am UTC](https://forum.choiceofgames.com/t/struggling-with-name-input/62885/40 "2019-10-12T07:04:56Z")

</div>

What I posted is just an example, not the true 100% functional copy-paste-this-it-works code. You have to edit and change it accordingly.

[Previous page](https://forum.choiceofgames.com/t/struggling-with-name-input/62885.md?page=1)

[Next page](https://forum.choiceofgames.com/t/struggling-with-name-input/62885.md?page=3)
