Thanks for the reply!
Yes… I know it can be done that way, but for doing that lots of times, wouldn’t it cause some kind of lag in the application?
What I want to do is use this to format my text in a easy way. I’m creating a function that agrupates lots of displayText objects and mounts them at the screen. But as I would be doing that, I would call display.newText() and display.remove() many times… Wouldn’t it sound a problem?
…
After some time thinking, yes, I would display every single text, so I could just render them and keep positioning until they are all OK. But, the reason I’m doing this is to fix a limitation inside the API, which is you can’t create a single TextObject with diferent colors .
So, I would like to break the string for a better concat in the screen if possible, and for that I would like to check if the textObject created has a greater width than the area I want right now (I want to create my own text wrapping).
I know it sounds complicated, but it’s like this:
I have some kind of list of strings:
list = {
“asd”, “gfh”, “zxc”,
}
and I want to display them as if it was a single textObject.
in the screen: “asdgfhzxc”
But, as i call my function to render it, I would have the option to color these small strings inside the list with different colors:
list = {
{“asd”, {1, 0, 0}},
{“gfh”, {0, 1, 0}},
{“zxc”, {0, 0, 1}},
}
So as i display it, it would be like this: “asdgfhzxc”
But there are larger textObjects, that are way to big. And if you set a width to text parameters, the resultant textObject will automatically wrap, and I wanted some kind of way to know where exactly is should be wrapping, so I can separate the strings and don’t lose any position when mounting the formatted textObject.
Giant_String = “asdasdadadasdasdasdadaadsads”
display.newText({
text = Giant_String,
width = 100,
})
In the screen:
100 px
|--------------------------------------|
asdasdadadasdasdasdadaad <- here it wraps. I wanted to know where in the string it happens before calling display.newText()
sads
So, that’s why I think your answer doesn’t solve so much of my problem, as I would call this too many times, the game or application would have too much unnecessary lag…
But, if there is a way to do this, pls tell me, that’s the reason i’m asking this question!