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?
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. |
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.
|
I'm hoping that when/if I get to filters in 511, that will be able to deal with outlines for maptext.
|
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.
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.
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.