I've managed to get the hp bar to show up on the player. But I can't get the bar to update when the hp is altered.
Does anyone have any advice? I've looked through the DM guide and didn't find much, I also checked out some tutorials on overlays. Any help would be most appreciated. Thanks.
ID:173998
Oct 15 2003, 8:50 am
|
|
Oct 15 2003, 6:56 pm
|
|
You need to remove the icon from the overlay list, make another overlay with the updated icon for the meter, then add that.
|
In response to Loduwijk
|
|
mob/player
icon='player.dmi' icon_state="fighter" var hp maxhp strength defence exp nextexp lvl obj hpbar icon='hpbar.dmi' icon_state="(round(([hp]/[maxhp]*100)/4),1)" I'm trying to define the object so I can use it as an overlay. I keep getting errors that hp and maxhp are undefined variables. What am I doing wrong? |
In response to OmniSlashX4
|
|
There are 2 problems:
1)"hp" and "maxhp" are not defined for obj/hpbar 2) You can't set an icon_state using variables (needs to be a constant) you can however change it in New() You can do something like: obj This assumes you only want it to be on players, and that you have the icon_state's a certain name. You could also do it as A.icon_state="[number]" to save the trouble of the special names for it (It was taken from a game I'm working on in which I figured it would be easier to do It like this). You also in this case need to call healthbar.update() (with arguements) everytime there is a change in hp. However it would not be hard to turn it into a loop if you would prefer to do it that way. |
In response to Nick231
|
|
Thank you, that seems to work, I'm just having a little trouble calling the proc. When I input the args what am I supposed to be inputing?
"call healthbar.update() (with arguements)"<< What I'm asking is what are the arguments I'm supposed to be inputting in there. Thanks |
In response to OmniSlashX4
|
|
You would do something like:
src.healthbar.update(src,src.hp,src.maxhp src just needs to be switched to whatever you are updating the healthbar of (Might be usr, or someother variable ie. if M.hp-=damage takes health from the player in a proc, then you would switch src with M). |
In response to Nick231
|
|
Ok THANKS! That worked phew. I'm such a newb lol. Thanks for helpin out.
|
In response to OmniSlashX4
|
|
you are declaring the maxhp/hp variables as OBJ variables.
you declared mob/variables up top but when you're using a procedure for an obj it uses obj variables, try to be more specific... |