ID:263221
 
Code:
mob
verb
Show_HP_Meter()
var/HPPP = /obj/HP
usr.overlays += HPPP


Problem description:When i try to use the verb, nothing happens

you may not be able to see the overlay...try changing the layer its on
In response to Shlaklava
Shlaklava wrote:
you may not be able to see the overlay...try changing the layer its on

obj/HP
name = "HP Meter"
icon='meter.dmi'
icon_state="power_100"
layer=MOB_LAYER+1

still nothing happens =/
Pharaoh Atem wrote:
Code:
mob
> verb
> Show_HP_Meter()
> var/HPPP = /obj/HP
> usr.overlays += HPPP
>

Problem description: When i try to use the verb, nothing happens


You're trying to overlay a type path. You need to create a new instance of the object, THEN overlay it.

mob
verb
Show_HP_Meter()
var/obj/HP/HPPP = new()
usr.overlays += HPPP
In response to Foomer
Actually, although I never do it myself, overlays list can handle object types added to it. It automatically creates a new image object with the appropriate information according to what an object of that type would have.

The overlays list can handle a lot of odd abuse like that, since it's all done internally all that functionality (abuse proof, from my point of view, which is not always a good thing) is built in.

Odd and counter-intuitive I know, but it does work.
Does your /obj/HP have an icon and icon_state set? What does the code for it look like? The problem can't be in that function that you showed, as that should work fine, and in fact it does for me.
In response to Loduwijk
obj/HP
name = "HP Meter"
icon='meter.dmi'
icon_state="power_100"
layer=MOB_LAYER+1

mob
verb
Show_HP_Meter()
var/obj/HP/HPPP = new()
usr.overlays += HPPP


still nothing happens
In response to Pharaoh Atem
That is odd. Did you overwrite /obj/HP/New at all? Do you have anything else in there that could alter it? Any other /obj/HP information not listed there?

Are you sure the icon_state is correctly set? Are you sure it's not supposed to be "power 100" instead of "power_100"?

I can't think of anything else at the moment that could cause it. It works just fine for me when I use the code you showed.
In response to Loduwijk
Loduwijk wrote:
That is odd. Did you overwrite /obj/HP/New at all? Do you have anything else in there that could alter it? Any other /obj/HP information not listed there?

Are you sure the icon_state is correctly set? Are you sure it's not supposed to be "power 100" instead of "power_100"?

I can't think of anything else at the moment that could cause it. It works just fine for me when I use the code you showed.
I overwrited.I searched, but i only find that.And yes, the state is correct.