Simple Text, take away characters of string?

Hey,

Been a while posting but i’m work on a menu that will display your avatar image, points and name.

Problem is that it’s placement is at the top right of the screen. What I want is so that the text whatever amount of characters is say - 20 away from the avatars image, is that possible?

Cause I know if you change the X And Y axis it moves it according to the top left of the text if that makes sense.

So something like;




draw.SimpleText( "Welcome to "..GetHostName(), "DermaLarge", ScrW() - 20 - GetHostName(), 20, Color(255,255,255,255), 0, 0 )



Like that but with player nick? any helps appreciated. Cheers! <3

You can get the string text actually, its in the stirng library >-<

If I understand correctly, you want to find out what the amount of characters in ply:Nick() is, in that case you can # it



#Player:Nick()
print(#player.GetAll()[1]:Nick(), " characters!")


Thanks a lot man, worked <3

[editline]12th August 2015[/editline]

I’ve just done it, it has worked but it only moves by 4 pixels (4 characters in my name) although the font is DermaLarge so it doesn’t really make any effect? any suggestions?

surface.GetTextSize

then use something like +2 or so, make it move 6 pixels instead of 4.

No, never. If you change font you will do all from start. Listen to PortalGod, example:



local nick = player.GetAll()[1]:Nick()
surface.SetFont("DermaLarge")
local x, y = surface.GetTextSize(nick)

draw.SimpleText( "Welcome "..nick, "DermaLarge", ScrW() - 20 - x / 2, 20, Color(255,255,255,255), 0, 0 )


CODE IS NOT TESTED, Should be something like that.

read closely, first(BEFORE NINJA) I wrote to use the textsize function, and then he could simple add more to the X

you could always change the alignment of the text using the last two arguments.