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

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
misaki_e
Posts: 20
Joined: Fri Apr 16, 2021 1:57 am

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

Post 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?
User avatar
Tony Li
Posts: 20751
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Hi,

Use the string.len() function:

minNameLength.png
minNameLength.png (35.3 KiB) Viewed 282 times
misaki_e
Posts: 20
Joined: Fri Apr 16, 2021 1:57 am

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

Post by misaki_e »

Awesome, thank you for illustrating that! This is greatly helpful!
User avatar
Tony Li
Posts: 20751
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Glad to help!
Post Reply