ID:153993
 
Not sure whether to put this here or in Newbie Central, but this is my best guess.

Anyway, I was thinking about the ways of refreshing something, like a HUD (which is in fact what I want to refresh). There are two simple ways to do this: make it refresh in Stat(), or manually call the refresh proc whenever I change a variable. The former way works, but causes unnecessary lag, and the latter way is annoying because you have to call that proc every single time.

I was wondering if it would be possible to make it check in Stat() whether or not a variable has been changed, and if it has been, it will refresh the HUD. The solution I have right now looks like this:
mob/var/HP = 50
mob/var/hud_HP = 50

mob/Stat()
if(hud_HP != HP)
hud_HP = HP
Refresh()

Of course, that would involve creating two variables for each stat I want to show on my hud, which would be a big pain. Is there an easier way of doing this?
The best way is to just create a standardized procedure that changes a variable and updates the corresponding HUD element; that way you still only need one line each time you change a variable.
In response to Leftley
Ah, thanks. I hadn't thought of that.