Preventing multiple-word name entry


I’m relatively new to Choicescript, so apologies if this is a really basic question. I’ve used the input text command to allow players to enter a pet’s name. This all works fine, however, my husband, being the ideally irritating tester he is, typed full sentences rather than a name, which obviously makes everything weird every time the pet’s name is used. Is there any way to prevent players doing this and limit them to a single or two-word text entry, or is this something I have to live with? (I guess they’re only spoiling it for themselves anyway!)



1 Like

You can do something like this:

*create name "" 
*label input_name
*input_text name
*temp index 0
*label check_name_loop
*if (index < length(name))
    *set index + 1
    *if ((name#index) = " ")
        Error: Don't use spaces!
        *goto input_name
    *goto check_name_loop

Thank you, I’ll give that a try!

Is there a way to limit the character length of a string?

@N0616307 6
I’d be wary of having a limit on the amount of spaces in a word. What if I want to call my pet Mr. Puddles, or my hat


Yes, this was my concern too. Perhaps it is better to leave it as it is. (Although I may try it for one round of testing, just to annoy my husband!)

*if (length(name) > allowed_limit)
    *goto input_name

You could add in an option to give your pet name prefix or suffix.

If you choose “Mr.”

*set petname “Mr. "
*Set petname &”${value of input}"

Tbh whenever you give people a text input field, they are likely to write something stupid. I remember the jokes about the Black Magic appearance being put in as ‘a jello cube.’ No matter how much space you give them, people will write a troll option. There’s no way around it. (I’m guilty of it myself, I always name my protagonist something idiotic and come to regret it later).


That’s why I’m never going to allow for input_text in my games. :stuck_out_tongue:

Personally, I really wouldn’t worry about it myself. It’s their game experience, and if they want to “ruin” it by entering a ridiculously long entry unto a text box, they’re the one who has to deal with it. I’d be pretty annoyed by an arbitrary character limit or having invalid characters for something like a name myself. Just my two and a half cents!


I definitely agree with this. By trying to keep people from “ruining it” for themselves, an author can easily ruin it for others – which is not to be preferred.


Yeah, I think you’re both right. As I said above, I may test it out, but will probably leave as is in the game.

1 Like