ID:266756
 
how do I make it where the hair color of an icon can change, but not the entire icon? in other words if I have an icon with black clothing and black hair, how do I make the hair color customizable while everything else is unchanged?
In response to Mertek
that doesn't help when the hair is part of the icon...
In response to Eagle Madigan
You'll have to make a new icon that contains just the hair. You can color it at runtime with rgb() or simply have preset colors that are each seperate icons. Then you attach the customized hair icon to the mob as an overlay.
Eagle Madigan wrote:
how do I make it where the hair color of an icon can change, but not the entire icon? in other words if I have an icon with black clothing and black hair, how do I make the hair color customizable while everything else is unchanged?

First, you need to make an icon with two states: One is called "body" and has the body and head. Make another called "hair", that's mostly white or shades of gray (or slightly off-white colors); this is going to be tinted by a color. You can do the same thing with clothes that you do with hair here, or you can just make clothes part of the body.

For the sake of example, let's say these icon states are now in player.dmi.
proc/CreateIcon(hair_r,hair_g,hair_b)
var/icon/bodyicon=new('player.dmi',"body")
var/icon/hairicon=new('player.dmi',"hair")
hairicon.Blend(rgb(hair_r,hair_g,hair_b),ICON_MULTIPLY)
bodyicon.Blend(hairicon,ICON_OVERLAY)
return fcopy_rsc(bodyicon)

However, the one drawback to this technique is that the final icon has no states except the default "". If you want to have icon states set up and everything, the process is more complicated.

First, you have to create multiple icon files. Make one for the body, one for the hair, and so on. Each file should have exactly the same icon states. If you use directional icons, they should have icons with the same directions. If you use animated icons, make the corresponding states in each icon file have the same number of frames. And so on.

Now, let's say these files are called player_body.dmi, player_hair.dmi, etc.
proc/CreateIcon(hair_r,hair_g,hair_b)
var/icon/bodyicon=new('player_body.dmi')
var/icon/hairicon=new('player_hair.dmi')
hairicon.Blend(rgb(hair_r,hair_g,hair_b),ICON_MULTIPLY)
bodyicon.Blend(hairicon,ICON_OVERLAY)
return fcopy_rsc(bodyicon)

The code isn't all that dissimilar--it's the extra icon work that could be a pain.

Lummox JR