Text Box questions

0 favourites
  • 6 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • I'm trying to make a fake translator, similar to google translate's layout.

    Regardless to what the player writes, the game counts the number of words in the textbox and gives as "translation" the same number of words by picking random words from a database.

    I've read the textbox guide but it's still beyond my comprehension. I wonder why it uses something as complex as CSS instead of being user friendly like the rest of Construct 2.

    I'd need:

    -to center the text top-left (I could center it horizontally with the "align" CSS command, but vertically it's always in the middle of the box)

    -to know the number of words written by the player in a textbox (words, not letters)

    -put automatic line breaks if the text exceeds the box's width while the player is writing

    Thank you in advance for your help and sorry, but I'm a total noob at this...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 1) use textarea as type

    2) loop through the text character by character, count words by logic like: stop counting as word when punctuation, newline or space follows, start counting a word when a character unlike punctuation etc appears.

    3) textarea does that automatically

  • Thanks a lot! I knew it was easier than I thought!

    Could you please help me on how to exactly tell construct to count the number of " " (empty spaces) in a sentence?

    I tried to count the number of times the player presses the spacebar, but they only get counted while he isn't typing in the textbox!

  • how to tell construct to count the number of " " (empty spaces) in a sentence?

    ...just a thought

    capx:

    http://s000.tinyupload.com/index.php?fi ... 8500618191

  • > how to tell construct to count the number of " " (empty spaces) in a sentence?

    >

    ...just a thought

    capx:

    http://s000.tinyupload.com/index.php?fi ... 8500618191

    That's great but I honestly can't understand what you did... I still have to learn about AJAX and Arrays, Ashley's guides about them are a bit too complex for a total noob like me...

    Could you please exactly point out to me which event counts the number of empty spaces?

    I'm sorry for the silly questions but you see, I still have to get a grasp of this...

  • TypeBox compare text.............trim(aTypeBox.Text)&" "

    so..let's say your:

    TypeBox Text= is "WORD(blank space) "

    ..then

    trim(TypeBox.Text) will be just "WORD"

    .. and

    trim(TypeBox.Text)&" " wil be "WORD"& "(blank space) "

    ...now you know you have blank space affter "WORD" <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    EDIT:

    anyway......... WadaKatsu forget it <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    for counting words you need something like this...

    capx:

    http://s000.tinyupload.com/index.php?fi ... 0273882192

    I still have to learn about AJAX and Arrays...

    ..now you can add Regular Expressions to list... <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    good starting point ... http://www.regexr.com/

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)