How do I change uppercase text back to sentence case?

0 favourites
  • 7 posts
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • Text object named BBCodeText

    Sprite named Button with a variable named Click

    Text object has text: I was on a walk at the beach when I saw David and Sarah.

    CONDITION (Add Capitalize)

    On tap gesture Button

    Button variable Click=0

    ACTION

    Set text to uppercase(BBCodeText.Text)

    Button set Click=1

    Result: Text is all caps

    I WAS ON A WALK AT THE BEACH WHEN I SAW DAVID AND SARAH.

    At this point, I have other conditions that would give options to underline. So the text could look like this.

    I WAS ON A WALK AT THE BEACH WHEN I SAW DAVID AND SARAH.

    CONDITION (Remove Capitalize)

    On tap gesture Button

    Button variable Click=1

    ACTION

    Set text to ?????? Is there an option to remove the uppercase. I know there is a lowercase

    option but I need sentence case.

    Button set Click=0

    Result needed: I was on a walk at the beach when I saw David and Sarah.

    I thought about saving the original text in a variable and replacing the text but it removes any bbcode I might have added.

  • Update, Result needed: I was on a walk at the beach when I saw David and Sarah.

  • why go to all caps if you just wanna revert it later?

  • I have a few applications, but one of them is if the user chooses wrong then the sentence becomes all caps. When they make changes and get it right then it goes back to sentence case.

  • The easiest solution is to save the text in a variable or dictionary before changing it to uppercase. Then, if user wants to revert back, simply restore the text from that variable. Like an Undo system.

  • The problem you're going to have with any algorithm to properly capitalize a sentence is none are really going to know what to do with names like David and Sarah. Most work by either splitting the string apart at the spaces looking for things that should be capitalized, like the single letter 'I'. Unless you stuff specific proper names into a structure like an array or dictionary, the algorithm won't know to capitalize them. The other solution is brute force guessing capitalization by running every word through a full dictionary and even that won't get it right all the time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There isn't a simple solution for this within Construct I believe. Easiest would be a revert option as you described yourself. But as it's not what you needed your best option would probably be javascript to split the first string to an array. and after you add your bbcode you compare the newstring to the array replacing all capitalized words.

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