• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

how to get substring real position?

I

itameio

Guest
Is there a way to get a substring's position relative to the room and not to the text? or maybe a way to get it by different means?.

What I'm basically doing is that I'm mixing draw_text_colour's string with string() function in order to make words with different colors in the same sentence and other stuff, So I'm including another draw_text_colour in the string() with different colours in order to that :

Code:
draw_text_colour(0,0,"hello, my name is " + string(draw_text_colour(0,0,"Itameio", c_blue,c_blue,c_teal,c_teal,1)) + ".", c_white,c_white,c_gray,c_gray,1)
What I want to do is to make the draw_text_colour function in the string() function to draw text right after the main draw_text_colour function, but i don't know how to deal with the position input, and I don't want to put it in manually everytime I use the code with different lengths of text.

oh, and if there is a better way to colorize different words in the same draw_text event, please do tell.
 

Llama_Code

Member
I think the best way to do this, would be to draw your main text, then use string_width/string_height to figure out where the main text ended, then draw the additional text at the same x/y as the main text + the string_width/height of the main text.

string_width gets the width in pixels of the text, string_height gets the height in pixels. Of course if you want to append directly to the previous string and its more than one line you would need to work out where the last line ended.

A bit of a hassle but that is really all I can think off....

You could get creative with string_copy and string_width to patchwork it together, but that could get crazy to.

Its easier when you are only trying to colorize specific words, like Zelda for example when a character is talking and they make meaningful words a different color.
 
Top