Is it possible to place a variable in a text paragraph?

Hello, I want to ask how do I place variables inside a text paragraph?


Here is an image for reference
And also, is it possible to change the text color of individual words inside a text object?

Imagine you have number variable called Bullets that shows how many ammo you have left

And you would wish to display something like Ammo 20

So you go with "Ammo "+Bullets

Re coloring individual characters is possible with bbtext object

I’m sorry but I can’t figure this out, can you provide me with examples? because I don’t know if it is possible in the event section nor do I know if its possible to make a paragraph there. I also can’t use arrays because I want to show different variables on the screen

I have no idea what arrays have to do here since it should not matter

Change text object text SET TO
Correct syntax

"Your text here "+VariableNameHere

So other example imagine your player have HP variable and player is called well Player and that var is set to 20
Now you want to display Health 20
So you go with

"Health "+Player.HP

And you get Health 20

Now let’s try distance between enemy and player
So you have Player object and Zombie object
And you want to display Player is 15 pixels away from Zombie
Assuming he is 15 pixels away
So change text object text SET TO

"Player is "+ToString(Player.DistanceToObject(Zombie))+" Pixels away from Zombie"

Bottom line what is between “” is just text then you use + add values/expressions
AND if you get red error that you try to display number you just add there ToString()

2 Likes

Ok so last question, is there an easy way to center text object on the screen? because they aren’t like sprite objects where you can manipulate their points, because I dont want to have to manually align it for every text objects I want.

Change position of Text set to

Center on Player
Player.CenterX()-Text.Width()/2 Player.CenterY()-Text.Height()/2

Center horizontally but put it above player head
Like he carry block
Player.CenterX()-Text.Width()/2 Player.Y()-Text.Height()

Center horizontally but put it above player head
With gap of height of text so you could fit another
Text object between player head and text object
Player.CenterX()-Text.Width()/2 Player.Y()-Text.Height()*2

Center text on center of screen
CameraCenterX()-Text.Width()/2 CameraCenterY()-Text.Height()/2

Center horizontally but put it next to top edge of screen
But offset it down so you could fit between top edge
And text object another text object
CameraCenterX()-Text.Width()/2 CameraBorderTop()+Text.Height()

There is CameraBorderTop() Left Right Bottom
And + means more down where - means more up if you put it in position for Y axis
Where for X axis + means more to the right and - means more to the left
You could go with static numbers
For example let’s say you want text object to be 14 pixels above player head

Player.CenterX()-Text.Width()/2 Player.CenterY()-Text.Height()-14