Name Text

by Red Hall Dev
Display player/object names under their icon.
ID:1882407
 
This demo will show a way to overlay text onto any player or object and centre it. To do this you can use a new type of object called Name_Text. It comes with 5 procs you can use.

/*
setText(text):
Set what text will be drawn

write():
Write the current set text on top of the object

clear():
Remove what was last written

setVerticalShift(number):
How many pixels up/down(positive/negative) you want to shift the text by.

setHorizontalShift(number):
How many pixels right/left(positive/negative) you want to shift the text by.
*/


From the demo:
mob
icon = 'Icons.dmi'
icon_state = "Player"

var
Name_Text/nameText

Login()
Move(locate(25,25,1))
nameText = new/Name_Text(src)
nameText.setVerticalShift(-11)
nameText.setText("Your name here")
nameText.write()
nameText.clear()

#IMPORTANT#

This is done using images. Images are naturally visible to no one. You MUST output images to each person in the game in order for other people to see them.

Like so:
                // Decide who sees the image
for(var/client/c)
c << nextImage


People may however join and leave a game meaning they weren't around when everyone was sent the image. Everyone will handle this a different way so I'm not going to include that as it would be a whole different demo altogether.

Jist of the message: If not everyone on your server can see a name then you're doing this wrong.
I'm going to note here that I'm not an artist but I drew all the characters used in the demo myself. That should explain anything wrong with them although I think they're 'okay'.