Page 1 of 1

How can I conditionally branch on the length of text entered in TextInput()?

Posted: Sun Nov 13, 2022 10:00 pm
by misaki_e
Hi,

If the player entered only one character as his/her name in the text input field, I would like to have a NPC ask the player something like "Are you sure?” How can I set the condition by the length of text entered?

Re: How can I conditionally branch on the length of text entered in TextInput()?

Posted: Mon Nov 14, 2022 9:34 am
by Tony Li
Hi,

Use the string.len() function:

minNameLength.png
minNameLength.png (35.3 KiB) Viewed 714 times

Re: How can I conditionally branch on the length of text entered in TextInput()?

Posted: Mon Nov 14, 2022 7:32 pm
by misaki_e
Awesome, thank you for illustrating that! This is greatly helpful!

Re: How can I conditionally branch on the length of text entered in TextInput()?

Posted: Mon Nov 14, 2022 7:55 pm
by Tony Li
Glad to help!