proc/remove_blanks(icon/a)
//removes any icon states that are not labeled
var/icon/ic = icon()
var/icon/m = icon(a, moving = 1)
var/icon/n = icon(a, moving = 0)
for(var/s in icon_states(m))
if(s != "")
ic.Insert(icon(m, s), s, moving = 1)
for(var/s in icon_states(n))
if(s != "")
ic.Insert(icon(n, s), s, moving = 0)
return ic
This does indeed do what it is supposed to do, remove all blank icon states and return the icon without the blanks. The only problem is, if the icon to return only contains one icon_state, icon.Width() returns 0 when it clearly is not!
Not sure why.