ID:1792801
 
(See the best response by Fushimi.)
Problem description:
Basically, I want to make a proc, that auto-centres the overlay or icon on the user because, I have to use
var/AURA = image(icon=src.icon,pixel_x = -31)

If the overlay's dimensions are higher than your player's icon, or the object's icon you are overlaying, that's the correct way to do so.
Hmm, I don't quite understand, could you explain more in detail please.
Best response
If the icon you want as overlay, has a size higher than the icon that's holding that overlay, you will have to offset pixels on the x & y axis accordingly.

DM does not provide any sort of function that automatically detects the size and offsets it, you would have to go write your own implementation.

Take a look into the icon.Height() and icon.Width() procedures.

EDIT2: I removed the old example, it was not working.
Here I provide an example that actually is easy to use:

proc/get_pixel_x(icon/base,  icon/overlay)
if(!base || !overlay) return 0
var w_b = base.Width()
var w_o = overlay.Width()
return round(((w_b - w_o) / 2),1)

proc/get_pixel_y(icon/base, icon/overlay)
if(!base || !overlay) return 0
var h_b = base.Height()
var h_o = overlay.Height()
return round(((h_b - h_o) / 2),1)



To use it you would just add an overlay like:
mob.overlays += image('TheOverlay.dmi',
pixel_x = get_pixel_x(icon(mob.icon), icon('TheOverlay.dmi')),
pixel_y = get_pixel_y(icon(mob.icon), icon('TheOverlay.dmi')))

Thanks alot ^.^