ID:146968
 
I am making a HUD system for Infantry Wars that is similar to that used in the Delta Force series. However, the procedure that changes the meter's icon when the player reaches a certain health percentage gives these errors:

loading INF.DME
loading MACROS.DMS
HUD.dm:14:error:healthm:undefined type: healthm
HUD.dm:15:error:T.icon_state:undefined var
HUD.dm:17:error:healthm:undefined type: healthm
HUD.dm:18:error:T.icon_state:undefined var
HUD.dm:13:error::missing expression
HUD.dm:16:error::missing expression
HUD.dm:14:healthm :warning: variable defined but not used
HUD.dm:17:healthm :warning: variable defined but not used.

These errors occur from the following code:

mob 
proc
health()
if(src.HP = "70") // Error on 13
for(var/T/obj/healthm in client.screen) /// Error on 14
T.icon_state = "70" // Error on 15
if(src.HP = "50") // Error on 16
for(var/T/obj/healthm in client.screen) // Error on 17
T.icon_state = "50" // Error on 18


I tried to combine it with the meter's New() proc as well as use the "M" defining strategy. None of that worked. Basically, I am asking for help to fix this procedure.
Drafonis wrote:
loading INF.DME
loading MACROS.DMS
HUD.dm:14:error:healthm:undefined type: healthm

You have your variable definition backwards. It's not var/T/obj/healthm, it's var/obj/healthm/T.

HUD.dm:15:error:T.icon_state:undefined var

This is because of the error above fix that, and this will be fixed.

HUD.dm:17:error:healthm:undefined type: healthm

This is also becuase of the first error.

HUD.dm:18:error:T.icon_state:undefined var

Same with this.

HUD.dm:13:error::missing expression

This is becuase you're not using if() properly. A single = means "Set this to that". You want double ==, which means "If this is equal to that".

HUD.dm:16:error::missing expression

Same as above

HUD.dm:14:healthm :warning: variable defined but not used

This is because of the first error. Your creating a variable called healthm, but not using it. Fix the first error, and this will be fixed.

HUD.dm:17:healthm :warning: variable defined but not used.

Same as above.

Try this:

mob 
> proc
> health()
> if(src.HP == "70")
> for(var/obj/healthm/T in client.screen)
> T.icon_state = "70"
> if(src.HP == "50")
> for(var/obj/healthm/T in client.screen)
> T.icon_state = "50"


~X