[workaround, help is welcome] Manipulation of text

Hi everyone,

During my game you can collect items with different values (1, 2,…) and I have a panel where I show the whole mathematical operation,

Every item has their variable and the sum is stored in another global variable that I transform to strings in a BBText object i.e. 1+2=3

Until now I have had 2 different text objects (one for the “1+2” and other for “=3” that works well) but I’m triying to keep updated and visible all the information of that panel only in one BBText object to keep simple the alligment and distance among the numbers

The idea is that every time the player collects a new value, the BBText updates itself cutting the text “1+2” until the “=”, and adding “+ new number = result”

But I’m having issues with the “manipulation of text” functionalityand I don’t know how to properly extract the first part of the text.

I’m trying to use “Get a portion of a text (SubStr)” mixed with “Search in a text (StrFind)” (to obtain the position of the “=” in the string)

But the text in the game just dissapears… anyone knows where is the error? (or maybe another way to achieve a solution)

“[outline=white]” +
SubStr(ScoreText.GetBBText(), 0, StrFind(ScoreText.GetBBText(), “=”))+"+"+ToString(Level_button.Animation())+"=" + GlobalVariableString(Total)+"[/outline]"

I’ve been exploring all the expressions here: Expressions reference [GDevelop wiki]

Thank you

After getting some sleep I realize that maybe I was overcomplicating thing and a simple and easier way to solve the problem is:

I’ve made another text object “Score” for all the operations i.e “1+2” (but this is not shown in the game)

And then I simple change another BBText object “ScoreText” with
“[outline=white]” +
Score.String() + “=” + GlobalVariableString(Total) +"[/outline]"

It works for me and solve the problem. Hope this can be useful for anyone in the future.

Anyway, If someone knows I’m still curious about if it’s posible and how to extract the text with “manipulation of text” formulas

2 Likes