ID:2050381
 
(See the best response by Nadrew.)
Problem description:

No code here, I'm just having trouble tackling this issue. In a project I want to get back working on, I've been aiming to display some mob statistics on the screen, just for aesthetic appeal.

For example, my mobs have a 'score' var, obviously meant to track points. In addition, I have DMI files meant to represent numbers and letters. How would I go about writing some code meant to process the score and display it on the screen -- while seamlessly changing the display in accordance to how my score rises or lower?
Best response
The most simple way is using the 'maptext' variable in conjunction with a screen object.

Since you mentioned you have icons for this stuff though things would be a little more complicated.

For both methods you'd have to keep track of changes to that variable, the ideal means of doing this is defining a proc that is called instead of changing the variable manually.

mob/proc/AddScore(value)
if(!value) return
src.score += value
UpdateScore()


In that example UpdateScore() would be where you change the on-screen stuff. As for the onscreen stuff I'm not gonna show you any code for that, instead I'll run you though one of the many possible methods to accomplish it.

Since you're not using maptext you'd need to loop over each character in the score variable, then as you're pulling each one off the variable you'd probably want to add the icon as an overlay to your screen object with some offsets applied to position them as desired. The state of the overlay would be set based on the value of each number in the score value. You'd probably want to keep a reference to the overlays so you can change their state without having to make a new overlay for it.

Now, if you went with maptext, things would be much, much easier.

mob
var/obj/score_display/score_display
proc/UpdateScore()
if(!score_display)
score_display = new()
client.screen += score_display
screen_score.maptext = "Score: [src.score]"

obj/score_display
maptext_width = 64
layer = 1024
screen_loc = "1,1"


Or something along those lines, this was all written off the top of my head... on my phone so don't expect things to compile or work out of the box, it is purely for educational purposes.
I'd recommend just using maptext instead of your own icons for fonts and scores, but, basically what you need is a proc that displays that information on the client's screen and updates it whenever it is changed. What you need to look into on the DM reference: maptext, client.screen, screen_loc. If you're dead-set on using your .dmi files, you just need to use copytext() to find out each digit/number on the string/score and set their icon_state to the corresponding letter/number.

EDIT: Whoops, Nadrew beat me to it.
Good advice @ Nadrew. I'll work on my program based off the example.

Also, the reason why I won't use map text is because it's so unappealing to the eyes. Would be sweet if we could modify out the map text rendered.
In response to Meme01
You can style it using HTML. Some things are limited on DS like shadow outline(but there's of course a workaround by making duplicates and setting them on each corner offsetting them), but you can get all of that on the webclient. You can also use animate() and whatnot. I think transform() is also supported now, but don't quote me on that.
In response to GreatPirateEra
I'm hoping that when/if I get to filters in 511, that will be able to deal with outlines for maptext.
In response to Lummox JR
Lummox JR wrote:
outlines for maptext.

Yes!