Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Word by word display of XML styled text acts weird: is there a fix?

Asked by 2 years ago
Edited 2 years ago

Gif that shows the problem: Link to imgur

I'm making a storygame where text is outputted word by word into a textlabel. Richtext is enabled, but when the text is word by word outputted on the textlabel, this system seems to not go so well with my XML stylizations of the text.

Here is the text I want to word by word show:

local introductionLine = [[
The virus spread faster than we could <u>control</u> it. 
We called it <stroke color="#ff0004" joins="miter" thickness="2" transparency="0.5">“The Red Signal”.</stroke>
It made people go insane, they were dangerous, if you got too close it was over. 
Now there’s only a few hundred thousand humans still existing. 
I believe that there’s still hope for humanity.
]]

And here is the function I use, where "s" is a variable for the whole string above.

for word in s:gmatch("%S+") do -- get words in the string
    storyTextLabel.Text = storyTextLabel.Text..word.." "
    wait(0.4)
end

Now is there any way I could avoid this problem? I'm thinking I could, for example, try to use, for string.sub in order to, from the string, extract the opener of the styling < and find the ending /> and instantly output it on the textlabel rather than word by word. I have not managed to be sucessful with that approach so far though. Any other suggestions/ideas/help would be greatly appreciated!

Answer this question