ID:1498947
 
(See the best response by LordAndrew.)
proc/refresh()
/* spawn(5)
if(barowner==null||!barowner||!src)del src
barowner.overlays-=src
invisibility=barowner.invisibility
if(barowner.name=="Tree")invisibility=20
var/percent=round((barowner.hp/barowner.maxhp)*100,10)
if(percent>100)percent=100
if(percent<0)percent=0
icon_state=num2text(percent)
barowner.overlays+=src
refresh() */

This code seems to generate an unusually high CPU usage. Is there perhaps a way to make the hp/mana bars refresh proc more efficient? At this point, I removed it because it causes the game to freeze
Best response
Instead of recursively calling refresh() infinitely, it'd be better to just have it so the bars only update if they need to (i.e. the player is hit, so tell the health bar to go down).
Ah yes, excellent. Thank you