Is it possible to put a variable inside text of a text object to make it say something like “You attacked for X damage” where “X” is a variable? Nothing I’ve tried seems to work.
You can display the content of a variable inside a text object using the “set text” action of it (you can’t do it from the scene editor, you need to update the text object’s text from the events).
The problem isn’t changing the text to show the variable, it’s putting that variable inside of other text. For instance:
Do ="You attacked for VariableString(DMG) damage" to the text of Messages
Do ="You attacked for" VariableString(DMG) "damage" to the text of Messages
Neither of which worked. The first one shows exactly what I put here (not translating “VariableString(DMG)” to a number) and the second one shows nothing at all. I even tried using variables to show the text:
Do =VariabeString(YouAttackedMSG) VariableString(DMG) VariableString(DamageMSG) to the text of Messages
where “VariabeString(YouAttackedMSG)” is set to “You attacked for” and “VariableString(DamageMSG)” is set to “damage”. This didn’t work either.
You need to use a ‘+’ sign to add variables to string, and also in case of number variables you need to convert the number to string using ToString() expression.
In case of String variable:
Do ="You attacked for " + VariableString(DMG) + " damage" to the text of Messages
In case of Number variable:
Do ="You attacked for " + ToString(Variable(DMG)) + " damage" to the text of Messages
ddabrahim: Thank you, that worked perfectly.