ID:146191
 
Code:
proc
iqloohudu(var/mob/m)
var
list
int[2]
int[1] = num2text(m.nHealth)
if(!copytext(int[1],2,3))
int[2] = "0"
else
int[2] = copytext(int[1],1,2)
for(var/obj/hud/nhealthfirst/nhf in m.client.screen)
nhf.icon_state = int[2]
if(copytext(int[1],2,3) == "0" || !copytext(int[1],2,3))
int[2] = "0"
else
int[2] = copytext(int[1],2,3)
for(var/obj/hud/nhealthlast/nhl in m.client.screen)
nhl.icon_state = int[2]
world << nhl.icon_state
int[1] = num2text(m.nProtection)
if(!copytext(int[1],2,3))
int[2] = "0"
else
int[2] = copytext(int[1],1,2)
for(var/obj/hud/narmorfirst/naf in m.client.screen)
naf.icon_state = int[2]
if(copytext(int[1],2,3) == "0" || !copytext(int[1],2,3))
int[2] = "0"
else
int[2] = copytext(int[1],2,3)
for(var/obj/hud/narmorlast/nal in m.client.screen)
nal.icon_state = int[2]
iqloohudm(var/mob/m)
var/icon/i
for(var/obj/hud/nhealthlast/n in m.client.screen)
i = new(n.icon,n.icon_state)
i.Shift(EAST,18)
n.icon = i
for(var/obj/hud/narmorlast/n in m.client.screen)
i = new(n.icon,n.icon_state)
i.Shift(EAST,18)
n.icon = i

[EDIT]
What this code is tring to do:
Overall this is the initalization and the updating of a numeric based health/armor/ammo etc display - with healtn and armor being the only things implimented.

The lower proc, "iqloohudm()" is what initalizes the two number display by shifting the second number over, as to not take up a vast ammount of space on the hud display, or forcing me to make icons for every number 1-99.

The upper proc, "iqloohudu()" is what updates the two numbers each time the variable the coorespond to is changed. This proc does this by coverting said variable into text, then uses copytext() along with some yes or no statements to figure out what the first and second number of the variable are.
[/EDIT]

Problem description:
When I attempt to update the icon state of the second number it refuses to update.

A "world << " tells me that my proc is telling it the correct icon state to change itself to.

I am not too adept in how BYOND handles icons, so I am nearly 100% sure that the problem rests the shifting of the second number, which occurs in the bottom proc, and 80% sure it has something to do with making the icon new(), but I don't know of any alternate ways to do the second proc.

[EDIT]
Aside from being able to help me make this work - if you have any way of better doing this process, also feel free to post, and it would be much appreciated.
[/EDIT]

Thank you in advance.
Why not use something along the lines of...

var/life = round(M.life/M.totallife*100,0.1) //Turn life into a percentage of 100
icon_state = "[life]" // Make the icon state whatever % life they have


Thats the most common approach
In response to Holy Retribution
Before I begin I would like to thank you, Holy Retribution, for your responce.

However, that in no way solves my problem.

If you were to look at code, or perhaps look a bit deeper, you would see that this code is not for that but instead it updates a numeric based HUD - meaning that if a person has 50 health, it will say - "50" - instead of having a bar that represented 50, via being half full, orange, or any other common represntation.

I, though, cannot blame you, as that would of helped someone who was aiming at that sort of hud, and would of been a very good way of doing it. Next time I will comment the code, and give an explination of what exactly im tring to do.

I would post another edition, commented to some degree, but it is rather late, and my time online this session is short, so in the mean time, please look at the code again.

Thank you again for your help.
In response to Iqloo
Well I made that post at about 2:30am myself, so I was kind of tired and just didn't have the energy to read it properly, I appologise for posting without reading, I'll look at it again when I've fully woken up.
In response to Holy Retribution
Thanks again (-: - sorry if the previous post sounded sarcastic, was a bit grumpy that early in the morning.