ID:2178726
 
Code:
atom/proc/AddLevel(var/Name2Add)
if(RedAlphabet=='Alphabet.dmi') RedAlphabet+=rgb(150,0,0)
if(!Name2Add) Name2Add="(XXX)"
var/letter=" "
var/spot=0
for(var/O in src.overlays)
if(O) if(O:name=="LevelDisplay") src.overlays-=O
else src.overlays-=O
while(src)
spot+=1
letter=copytext(Name2Add,spot,spot+1)
if(!letter) return
var/px=(length(src.name)*6/2)+spot*6
var/obj/NL=new/obj/Supplemental/NameDisplay(px,letter)
if(istype(src,/mob/Enemy/Bosses)) NL.icon=RedAlphabet
NL.name="LevelDisplay"
src.overlays+=NL


Problem description:im getting runtime erros like

runtime error: bad icon operation
proc name: AddLevel (/atom/proc/AddLevel)
source file: Procs.dm,536
usr: Ground Hollow (/mob/Enemy/Hollows/Ground_Hollow)
src: Ground Hollow (/mob/Enemy/Hollows/Ground_Hollow)
call stack:
Ground Hollow (/mob/Enemy/Hollows/Ground_Hollow): AddLevel(" (2)")
Ground Hollow (/mob/Enemy/Hollows/Ground_Hollow): LevelShift(2)
Ground Hollow (/mob/Enemy/Hollows/Ground_Hollow): New(Grass (32,12,1) (/turf/Soul_Society/Grass))
for(var/O in src.overlays)
if(O) if(O:name=="LevelDisplay") src.overlays-=O
else src.overlays-=O


I'm really not sure what the hell you're trying to do there... but I'm pretty sure that's where your issue is. It seems like you're trying to cycle through obj overlays (you need to typecast this, which is probably where that "bad icon operation" is coming from -- I'm 99.99% sure you can't subtract a variable from someone's overlays) and if it has a certain name you take it out of their overlays, and if it doesn't have that name... you do the exact same thing. Don't see the logic there at all.

Edit: Just reread it and realized you actually subtract the overlay if the overlay doesn't... doesn't... doesn't exist. If O doesn't exist the loop wouldn't be there. Incredibly redundant.
The whole thing with the icon manipulation is probably overkill anyway. You can use the color var on atoms and overlays to give the icon whatever color you want. If you start with white, you can multiply by a simple color; or you can do more complex color operations with a color matrix.